skillfed

zlib-ng

Drop-in replacement for zlib and gzip modules using zlib-ng

zlib-ng v1.0.0 1.8M downloads/30d#3,582 on PyPI15
Permissive license PSF-2.0 Active released

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-ng

uv

uv add zlib-ng

poetry

poetry add zlib-ng

Installing 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

Development Status :: 5 - Production/StableOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: CProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: System :: Archiving :: Compression

Tags

fast zlib compressiongzip performance replacementzlib-ng python bindingsaccelerated deflate compressiondrop-in zlib replacement
compressionperformance-optimization

More Compression packages