Metadata-Version: 2.4
Name: pidna
Version: 0.1.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Rust
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
License-File: LICENSE
Summary: Fast drop-in replacement for idna in Python
Keywords: idna,uts46,punycode,dns,domain,unicode,rust
License-Expression: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://github.com/gatewaytofredom/pidna
Project-URL: Repository, https://github.com/gatewaytofredom/pidna

# pidna

[![CI](https://github.com/gatewaytofredom/pidna/actions/workflows/ci.yml/badge.svg)](https://github.com/gatewaytofredom/pidna/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/pidna.svg)](https://pypi.org/project/pidna/)
[![Python Versions](https://img.shields.io/pypi/pyversions/pidna.svg)](https://pypi.org/project/pidna/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/gatewaytofredom/pidna/blob/main/LICENSE)

A fast drop-in replacement for `idna` in Python. Validates and converts internationalized domain names (IDNA 2008 and UTS #46) up to 418x faster on ASCII domains and 10–16x faster on Unicode domains.

## Install

```bash
pip install pidna
```

Prebuilt wheels are included for Linux, macOS, and Windows (Python 3.9+, no Rust toolchain needed).

## Usage

```python
import pidna

encoded = pidna.encode("münchen.de")       # b"xn--mnchen-3ya.de"
decoded = pidna.decode(b"xn--mnchen-3ya.de")  # "münchen.de"
uts46 = pidna.encode("API.GitHub.COM", uts46=True)  # b"api.github.com"
```

## Performance

| Workload | `idna` (x86-64) | `pidna` (x86-64 AVX2) | `pidna` (Apple M4 NEON) |
|---|---:|---:|---:|
| Small ASCII (`api.github.com`, 50k) | 408.97 ms | 6.02 ms (**68.0x**) | 5.78 ms (**47.0x** vs M4 `idna`) |
| Medium ASCII UTS #46 (`API.GitHub.COM`, 50k) | 466.38 ms | 9.54 ms (**48.9x**) | 8.81 ms (**31.3x** vs M4 `idna`) |
| Long ASCII (8 labels, 20k) | 1501.13 ms | 3.59 ms (**418.1x**) | 3.45 ms (**286.2x** vs M4 `idna`) |
| Unicode UTS #46 (`münchen.de`, 20k) | 243.33 ms | 24.59 ms (**9.9x**) | 18.94 ms (**7.0x** vs M4 `idna`) |
| CJK (`例え.jp`, 20k) | 179.37 ms | 10.93 ms (**16.4x**) | 7.28 ms (**15.1x** vs M4 `idna`) |

## Under the hood

- Written in Rust (PyO3) with zero external runtime dependencies and runtime SIMD dispatch (AVX2 / SSE2 / ARM64 NEON)
- Compact `cp39-abi3` wheel with PEP 561 type stubs (`py.typed` + `__init__.pyi`)
- Verified with Hypothesis differential fuzzing against `idna`

## License

MIT

