Skip to main content

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 main 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.

There are also two additional functions:

shuffle(data, output, itemsize)

unshuffle(data, output, itemsize)

Shuffle rearranges bytes in a way that often allows for better compression of numeric data: shuffling b"ababab" with an itemsize of 2 gives b"aaabbb". Unshuffle does the reverse. This is the same as the shuffle filter built in to HDF5.

For now, itemsize can only be 2, 4, or 8. The same operations can be done for any itemsize using NumPy views to transpose bytes, but the more specific code can be faster.

Metadata

Release files for zlib-into 0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zlib-into 0.4
File Size Uploaded
zlib_into-0.4.tar.gz 11.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for zlib-into 0.4
File
zlib_into-0.4-cp313-cp313t-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl CPython 3.13 CPython 3.13 free-threading Linux glibc 2.34+ x86-64, Linux glibc 2.5+ x86-64 Details
zlib_into-0.4-cp313-cp313-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.5+ x86-64, Linux glibc 2.34+ x86-64 Details
zlib_into-0.4-cp312-cp312-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64, Linux glibc 2.5+ x86-64 Details
zlib_into-0.4-cp311-cp311-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ x86-64, Linux glibc 2.5+ x86-64 Details
zlib_into-0.4-cp310-cp310-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.34+ x86-64, Linux glibc 2.5+ x86-64 Details

Total release size: 166.8 kB

Release files / zlib_into-0.4.tar.gz

Download URL zlib_into-0.4.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
767aef73038b11bccf148d618340b926d3f80b67b51e8cf484c5d563535e6889
BLAKE2b-256 checksum
How to use checksums
63b40e3cffb5cf54958646eae5952a0c2ab06856d64577126ecf577f7a936367
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / zlib_into-0.4-cp313-cp313t-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl

Download URL zlib_into-0.4-cp313-cp313t-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Size 31.8 kB
Tags CPython 3.13 CPython 3.13 free-threading Linux glibc 2.34+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
deee5a23d68d52399d523df8a968cd152d36608e0698c21022a7260a66657150
BLAKE2b-256 checksum
How to use checksums
18a05bf6644130ca5191a93640363a54e10df0328f7cd6067cfd30de3979b2df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / zlib_into-0.4-cp313-cp313-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl

Download URL zlib_into-0.4-cp313-cp313-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Size 31.1 kB
Tags CPython 3.13 Linux glibc 2.34+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
bb0e693259c4210a1646883f745ba80bcc262f35ff5145865a32e9ffd28aabb9
BLAKE2b-256 checksum
How to use checksums
b886258a1307ca96a40c0d1408a1335213223f8f9d02dfb9562247bdfe303429
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / zlib_into-0.4-cp312-cp312-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl

Download URL zlib_into-0.4-cp312-cp312-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Size 31.1 kB
Tags CPython 3.12 Linux glibc 2.34+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
58730fb59e688b3bea7cd0d26e4c27aa54b7d9aae790fcaf49353cd644859668
BLAKE2b-256 checksum
How to use checksums
33c4a8fbf7b192ede1d69e33324cc6490a8ca74dedccea25ca4d48f9a4a13c5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / zlib_into-0.4-cp311-cp311-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl

Download URL zlib_into-0.4-cp311-cp311-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Size 31.2 kB
Tags CPython 3.11 Linux glibc 2.34+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
1ab74be2057f7662c752ffb58593df25e7ce6a2062de34e96d92495f49566bdd
BLAKE2b-256 checksum
How to use checksums
0d95a1bfcba09892f85c556a8c2b74bb224f4fecedf1489ece6b5eac03bb531b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / zlib_into-0.4-cp310-cp310-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl

Download URL zlib_into-0.4-cp310-cp310-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Size 30.5 kB
Tags CPython 3.10 Linux glibc 2.34+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
4569ea9fa3c3dd8ddcf62a3a7ac22271b12e08f31432db8e471e7fcffe93d97b
BLAKE2b-256 checksum
How to use checksums
c1165f754bb51b3d4882325d40b368e4250e00fbdd2fc6f7611af14e44717b49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.4 This release

6 release files

0.3

6 release files

0.2

10 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page