Metadata-Version: 2.4
Name: phpack
Version: 0.1.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
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 HPACK header compression for HTTP/2 in Python
Keywords: hpack,http2,header-compression,rust,fast
License: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://github.com/gatewaytofredom/phpack
Project-URL: Issues, https://github.com/gatewaytofredom/phpack/issues
Project-URL: Repository, https://github.com/gatewaytofredom/phpack

# phpack

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

Fast drop-in HPACK header compression and decompression for HTTP/2 in Python, delivering 6.1x–7.4x faster header encoding and decoding than pure-Python `hpack` with zero API changes.

## Install

```bash
pip install phpack
```

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

## Usage

```python
import phpack

encoder = phpack.Encoder()
decoder = phpack.Decoder()

wire = encoder.encode([(":method", "GET"), (":path", "/"), ("accept", "application/json")])
headers = decoder.decode(wire)
```

## Performance

| Workload | `hpack` (x86-64) | `phpack` (x86-64 AVX2) | `phpack` (Apple M4 NEON) |
|---|---:|---:|---:|
| Small (4 headers, 10k iters) | 89.65 ms | 14.75 ms (6.08x) | 11.53 ms (5.21x vs M4 `hpack`) |
| Medium (10 headers, 5k iters) | 130.76 ms | 17.65 ms (7.41x) | 14.78 ms (5.24x vs M4 `hpack`) |
| Large (40 headers, 1k iters) | 99.21 ms | 15.18 ms (6.54x) | 11.85 ms (5.60x vs M4 `hpack`) |

## 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`)

## License

MIT

