zlib-ng
Drop-in replacement for zlib and gzip modules using zlib-ng
What it is and what it does
zlib-ng wraps the zlib-ng C library to provide faster compression and decompression than Python's built-in zlib and gzip modules. It offers three modules: zlib_ng (a zlib replacement), gzip_ng (a gzip replacement), and gzip_ng_threaded (which adds multi-threaded streaming for large files). All three are designed to be nearly drop-in replacements for their standard library counterparts, with the same API and behavior—the main difference is speed. The package includes a command-line tool (python -m zlib_ng.gzip_ng) that mimics the standard gzip utility.
The package is built from C extensions and requires compilation or platform-specific wheels during installation. It supports Linux, macOS, and Windows across multiple architectures. There are minor differences from the standard library: compression level 1 produces worse compression ratios than standard zlib, and gzip_ng.open returns GzipNGFile instead of GzipFile (though GzipFile is aliased for compatibility). No runtime dependencies are required once installed.
Use it for:
- Replace zlib in data processing pipelines where compression speed is a bottleneck and standard library performance is insufficient.
- Accelerate gzip-based file I/O in applications that read or write many compressed files.
- Stream large compressed files using gzip_ng_threaded to parallelize I/O and escape Python's GIL.
- Implement gzip-compatible command-line compression tools with better performance than the standard gzip utility.
- Reduce latency in HTTP compression workflows where zlib is the bottleneck in request/response handling.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides faster zlib and gzip compression and decompression by wrapping the zlib-ng library with Python bindings that serve as drop-in replacements for the standard library modules.
Yes, if you need faster compression/decompression and can tolerate medium install friction (compiled wheels). The package is actively maintained, has no known vulnerabilities, is permissively licensed, and offers a true drop-in replacement API. Install only if your workload is actually bottlenecked on compression—the standard library zlib is sufficient for most use cases.
Install
zlib-ng on PyPI
pip
pip install zlib-nguv
uv add zlib-ngpoetry
poetry add zlib-ngInstalling zlib-ng
Before you install
Medium install friction due to compiled C extensions requiring platform-specific wheels. Wheels are available for common platforms (Linux x86_64/aarch64, macOS x86_64/arm64, Windows x64) across Python 3.10–3.12, with active maintenance and no runtime dependencies.
License in practice
Licensed under PSF-2.0 (permissive), allowing use in most projects without significant restrictions.
Quickstart
pip install zlib-ng
from zlib_ng import zlib_ng
compressed = zlib_ng.compress(b'data')
decompressed = zlib_ng.decompress(compressed)
Requires Python 3.9 or later; platform-specific wheels may not be available for all architectures.
Verify before relying
- Actual performance improvement magnitude compared to standard library zlib across different workloads and compression levels.
- Full compatibility surface with standard library zlib and gzip beyond the documented minor differences.
- Support status for Python 3.13 and 3.14 (listed in classifiers but not in wheel evidence).
Package facts
| License | PSF-2.0 (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 338 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,761,783/month — #3,582 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: zlib_ng-1.0.0-cp310-cp310-macosx_10_9_x86_64.whl; zlib_ng-1.0.0-cp310-cp310-macosx_11_0_arm64.whl; zlib_ng-1.0.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; zlib_ng-1.0.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; zlib_ng-1.0.0-cp310-cp310-musllinux_1_2_aarch64.whl; zlib_ng-1.0.0-cp310-cp310-musllinux_1_2_x86_64.whl; zlib_ng-1.0.0-cp310-cp310-win_amd64.whl; zlib_ng-1.0.0-cp311-cp311-macosx_10_9_x86_64.whl; zlib_ng-1.0.0-cp311-cp311-macosx_11_0_arm64.whl; zlib_ng-1.0.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; zlib_ng-1.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; zlib_ng-1.0.0-cp311-cp311-musllinux_1_2_aarch64.whl; zlib_ng-1.0.0-cp311-cp311-musllinux_1_2_x86_64.whl; zlib_ng-1.0.0-cp311-cp311-win_amd64.whl; zlib_ng-1.0.0-cp312-cp312-macosx_10_13_x86_64.whl; zlib_ng-1.0.0-cp312-cp312-macosx_11_0_arm64.whl; zlib_ng-1.0.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; zlib_ng-1.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; zlib_ng-1.0.0-cp312-cp312-musllinux_1_2_aarch64.whl; zlib_ng-1.0.0-cp312-cp312-musllinux_1_2_x86_64.whl
Keywords: zlib-ng, zlib, compression, deflate, gzip
Tags
More Compression packages
Provides Python bindings to the Brotli…
permissive · top 1,000 on PyPI
backports.zstdProvides Zstandard compression support for…
permissive · top 1,000 on PyPI
zopfliZopfli is a Python binding for Google's Zopfli…
permissive · top 1,000 on PyPI
python-snappyPython binding for Google's Snappy compression…
permissive · top 5,000 on PyPI
pyzipperpyzipper replaces Python's standard zipfile…
permissive · top 5,000 on PyPI
pyzstdProvides Python bindings to the Zstandard…
permissive · top 5,000 on PyPI
aiohttp-zlib-ngReplaces aiohttp's default zlib compression…
permissive · top 15,000 on PyPI
deflateThin Python wrapper around libdeflate for fast…
permissive · top 15,000 on PyPI
isalProvides Python bindings for Intel's ISA-L…
permissive · top 5,000 on PyPI
zlib-stateProvides low-level access to zlib decompression…
permissive · top 15,000 on PyPI
lz4Python bindings for the LZ4 compression…
permissive · top 1,000 on PyPI
aiohttp-fast-zlibReplaces aiohttp's default zlib compression…
permissive · top 5,000 on PyPI
bz2fileProvides a drop-in replacement for Python's…
permissive · top 15,000 on PyPI
cmeel-zlibProvides zlib 1.3.2 as a pre-built wheel for…
permissive · top 15,000 on PyPI
mgzipmgzip provides a drop-in replacement for…
permissive · top 15,000 on PyPI