Skip to main content

Compress & decompress data with zlib into preallocated buffers

Project description

zlib_into allows Python code to compress & decompress data into a preallocated buffer.

The zlib module in the Python standard library provides an interface to zlib, a common library for Deflate compression, but always automatically allocates memory for the output.

zlib_into defines two functions:

compress_into(data, output, level=-1, wbits=15)

decompress_into(data, output, wbits=15)

In each case, output can be a bytearray, memoryview, Numpy array, or anything else compatible with Python’s buffer protocol exposing a contiguous, writable chunk of memory.

The other parameters have the same meanings as in zlib.compress and zlib.decompress.

This can be useful for:

  • Decompressing regular chunks of a known size: you can allocate a single output array and fill each chunk directly, avoiding an extra copy.

  • Compressing chunks when you want to skip compression if it would make the data larger: use a fixed-size buffer matching the input chunk size. Again you can avoid unnecessary memory allocations by reusing the buffer.

  • Imposing a size limit on decompressed data: it will stop decompressing (and throw an error) when the buffer is full, instead of decompressing the whole thing to see how big it is. But note that security on untrusted input is not the primary goal of this library.

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_into-0.3.tar.gz (9.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

zlib_into-0.3-cp313-cp313t-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl (21.6 kB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.34+ x86-64manylinux: glibc 2.5+ x86-64

zlib_into-0.3-cp313-cp313-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl (21.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64manylinux: glibc 2.5+ x86-64

zlib_into-0.3-cp312-cp312-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl (21.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64manylinux: glibc 2.5+ x86-64

zlib_into-0.3-cp311-cp311-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl (21.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64manylinux: glibc 2.5+ x86-64

zlib_into-0.3-cp310-cp310-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl (21.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64manylinux: glibc 2.5+ x86-64

File details

Details for the file zlib_into-0.3.tar.gz.

File metadata

  • Download URL: zlib_into-0.3.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for zlib_into-0.3.tar.gz
Algorithm Hash digest
SHA256 60f549516f7d8598110d90a4f9a494e5076f2846aecbb14894503820a95e0996
MD5 b922a80a7a30b1994919399942f288d3
BLAKE2b-256 db522fd19d3686c4f44a6a6435984851959ead15c88f5e2df873ba93876d70ab

See more details on using hashes here.

File details

Details for the file zlib_into-0.3-cp313-cp313t-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for zlib_into-0.3-cp313-cp313t-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 bd68c4072a5635fc14f7cf51d553f60e15d03431358d667b21f7ce655a30399f
MD5 23bbb792418fafe6e581a0ec75e9a18b
BLAKE2b-256 57da59294f1ea014959085f179415f19f0395dc2b2ea66ed6c2ca02cbf431bd3

See more details on using hashes here.

File details

Details for the file zlib_into-0.3-cp313-cp313-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for zlib_into-0.3-cp313-cp313-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 88c9e4241a657a10fb8a21f3a04f65443cae3bce98d6295a40808736408eaddf
MD5 173daf512063c2856c025f92d64316d2
BLAKE2b-256 eac4dc0f69cc139e73899b3e4010f65623c60e3b8955f169631373464607e8c9

See more details on using hashes here.

File details

Details for the file zlib_into-0.3-cp312-cp312-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for zlib_into-0.3-cp312-cp312-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 4108dc0e1278cdf184e9bc16851aa7853abc40b9e543a34892cd6b3822876fc2
MD5 af44c1f55059055910f0be6f98c121b1
BLAKE2b-256 6b5f3908017c42849f8784822ba334e36f4f7cdc0f8995dc34d4e18c13554144

See more details on using hashes here.

File details

Details for the file zlib_into-0.3-cp311-cp311-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for zlib_into-0.3-cp311-cp311-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 fad0d5d8bf4ba9c235ad6bdfae1871b8e3ac8cc631da70915cb49ba5db5d7e88
MD5 1183642a9093a64f7889c66a93208d98
BLAKE2b-256 05e6bb9b6d2e8a530452f0a16379e9f6e46603d717bec0ae5796335dec74842d

See more details on using hashes here.

File details

Details for the file zlib_into-0.3-cp310-cp310-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for zlib_into-0.3-cp310-cp310-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 ae717a24ef5ab3c04bd457b1e2d6be28f1cbd7fb2bd31f5d1545156c873e43bf
MD5 4439763277d3a31b877ef71d1a776f99
BLAKE2b-256 1bda304255c5546ed90d2cc45d72a1608a33e9f34cb0c9ec50c547c8d0913dcd

See more details on using hashes here.

Supported by

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