Skip to main content

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

Project description

python-zlib-ng

Faster zlib and gzip compatible compression and decompression by providing Python bindings for the zlib-ng library.

This package provides Python bindings for the zlib-ng library.

python-zlib-ng provides the bindings by offering three modules:

  • zlib_ng: A drop-in replacement for the zlib module that uses zlib-ng to accelerate its performance.

  • gzip_ng: A drop-in replacement for the gzip module that uses zlib_ng instead of zlib to perform its compression and checksum tasks, which improves performance.

  • gzip_ng_threaded offers an open function which returns buffered read or write streams that can be used to read and write large files while escaping the GIL using one or multiple threads. This functionality only works for streaming, seeking is not supported.

zlib_ng and gzip_ng are almost fully compatible with zlib and gzip from the Python standard library. There are some minor differences see: differences-with-zlib-and-gzip-modules.

Quickstart

The python-zlib-ng modules can be imported as follows

from zlib_ng import zlib_ng
from zlib_ng import gzip_ng
from zlib_ng import gzip_ng_threaded

zlib_ng and gzip_ng are meant to be used as drop in replacements so their api and functions are the same as the stdlib’s modules.

A full API documentation can be found on our readthedocs page.

python -m zlib_ng.gzip_ng implements a fully featured gzip-like command line application (just like python -m gzip, but better). Full usage documentation can be found on our readthedocs page.

Installation

  • with pip: pip install zlib-ng

  • with conda: conda install python-zlib-ng

Installation is supported on Linux, Windows and MacOS. For more advanced installation options check the documentation.

python-zlib-ng as a dependency in your project

zlib-ng supports numerous platforms but not all of these have pre-built wheels available. To prevent your users from running into issues when installing your project please list a python-zlib-ng dependency as follows.

setup.cfg:

install_requires =
    zlib-ng; platform.machine == "x86_64" or platform.machine == "AMD64"

setup.py:

extras_require={
    ":platform.machine == 'x86_64' or platform.machine == 'AMD64'": ['zlib-ng']
},

Differences with zlib and gzip modules

  • Compression level 1 zlib_ng has a worse compression rate than that in zlib. For other compression levels zlib_ng compresses better.

  • gzip_ng.open returns a class GzipNGFile instead of GzipFile. Since there are differences between the compressed ratios between levels, a difference in naming was chosen to reflect this. gzip_ng.GzipFile does exist as an alias of gzip_ng.GzipNGFile for compatibility reasons.

Contributing

Please make a PR or issue if you feel anything can be improved. Bug reports are also very welcome. Please report them on the github issue tracker.

Acknowledgements

This project builds upon the software and experience of many. Many thanks to:

  • The zlib-ng contributors for making the zlib-ng library.

  • The CPython contributors. Python-zlib-ng mimicks zlibmodule.c and gzip.py from the standard library to make it easier for python users to adopt it.

  • The github actions team for creating the actions CI service that enables building and testing on all three major operating systems.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zlib_ng-0.4.3.tar.gz (2.5 MB view hashes)

Uploaded Source

Built Distributions

zlib_ng-0.4.3-pp310-pypy310_pp73-win_amd64.whl (88.7 kB view hashes)

Uploaded PyPy Windows x86-64

zlib_ng-0.4.3-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (105.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

zlib_ng-0.4.3-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (96.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

zlib_ng-0.4.3-pp310-pypy310_pp73-macosx_10_9_x86_64.whl (101.1 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

zlib_ng-0.4.3-pp39-pypy39_pp73-win_amd64.whl (88.7 kB view hashes)

Uploaded PyPy Windows x86-64

zlib_ng-0.4.3-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (105.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

zlib_ng-0.4.3-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (96.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

zlib_ng-0.4.3-pp39-pypy39_pp73-macosx_10_9_x86_64.whl (101.1 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

zlib_ng-0.4.3-pp38-pypy38_pp73-win_amd64.whl (88.7 kB view hashes)

Uploaded PyPy Windows x86-64

zlib_ng-0.4.3-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (105.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

zlib_ng-0.4.3-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (96.1 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

zlib_ng-0.4.3-pp38-pypy38_pp73-macosx_10_9_x86_64.whl (101.1 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

zlib_ng-0.4.3-cp312-cp312-win_amd64.whl (88.5 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

zlib_ng-0.4.3-cp312-cp312-musllinux_1_1_x86_64.whl (111.9 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.1+ x86-64

zlib_ng-0.4.3-cp312-cp312-musllinux_1_1_aarch64.whl (101.5 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.1+ ARM64

zlib_ng-0.4.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (108.1 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

zlib_ng-0.4.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (98.5 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

zlib_ng-0.4.3-cp312-cp312-macosx_10_9_x86_64.whl (101.2 kB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

zlib_ng-0.4.3-cp311-cp311-win_amd64.whl (88.4 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

zlib_ng-0.4.3-cp311-cp311-musllinux_1_1_x86_64.whl (111.7 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

zlib_ng-0.4.3-cp311-cp311-musllinux_1_1_aarch64.whl (101.5 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ ARM64

zlib_ng-0.4.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (107.9 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

zlib_ng-0.4.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (98.5 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

zlib_ng-0.4.3-cp311-cp311-macosx_10_9_x86_64.whl (101.1 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

zlib_ng-0.4.3-cp310-cp310-win_amd64.whl (88.4 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

zlib_ng-0.4.3-cp310-cp310-musllinux_1_1_x86_64.whl (111.7 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

zlib_ng-0.4.3-cp310-cp310-musllinux_1_1_aarch64.whl (101.5 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ ARM64

zlib_ng-0.4.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (107.9 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

zlib_ng-0.4.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (98.5 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

zlib_ng-0.4.3-cp310-cp310-macosx_10_9_x86_64.whl (101.1 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

zlib_ng-0.4.3-cp39-cp39-win_amd64.whl (88.4 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

zlib_ng-0.4.3-cp39-cp39-musllinux_1_1_x86_64.whl (111.7 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

zlib_ng-0.4.3-cp39-cp39-musllinux_1_1_aarch64.whl (101.5 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ ARM64

zlib_ng-0.4.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (107.9 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

zlib_ng-0.4.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (98.5 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

zlib_ng-0.4.3-cp39-cp39-macosx_10_9_x86_64.whl (101.1 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

zlib_ng-0.4.3-cp38-cp38-win_amd64.whl (88.4 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

zlib_ng-0.4.3-cp38-cp38-musllinux_1_1_x86_64.whl (111.8 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

zlib_ng-0.4.3-cp38-cp38-musllinux_1_1_aarch64.whl (101.5 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ ARM64

zlib_ng-0.4.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (108.0 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

zlib_ng-0.4.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (98.6 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

zlib_ng-0.4.3-cp38-cp38-macosx_10_9_x86_64.whl (101.1 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page