Metadata-Version: 2.4
Name: ph11-rs
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 :: Internet :: WWW/HTTP
Classifier: Typing :: Typed
License-File: LICENSE
Summary: Fast drop-in replacement for h11 HTTP/1.1 protocol parser
Keywords: http,http11,h11,parser,protocol,httpx,httpcore,uvicorn
License-Expression: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://github.com/gatewaytofredom/ph11-rs
Project-URL: Repository, https://github.com/gatewaytofredom/ph11-rs

# ph11-rs

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

Fast drop-in replacement for `h11` that speeds up HTTP/1.1 request and response parsing and serialization by up to 13.7x.

## Install

```bash
pip install ph11-rs
```

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

## Usage

```python
import ph11

conn = ph11.Connection(ph11.SERVER)
conn.receive_data(b"GET / HTTP/1.1\r\nHost: example.com\r\n\r\n")
request = conn.next_event()
```

## Performance

| Workload | `h11` | `ph11` (x86-64) | `ph11` (Apple M4) |
|---|---:|---:|---:|
| Small Request (parse+send) | 44.49 us | 3.24 us (13.73x) | 2.41 us (6.97x) |
| Medium Request (8 hdrs+256B) | 57.71 us | 4.23 us (13.64x) | 3.34 us (6.92x) |
| Large Chunked Resp (16 KiB) | 105.61 us | 7.67 us (13.77x) | 5.79 us (8.88x) |

## 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 `h11`, 8-thread concurrency tests, and `tracemalloc` leak checks

## License

MIT

