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.2.tar.gz (17.1 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.2-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.2-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_x86_64.whl (26.7 kB view details)

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

zlib_into-0.2-cp313-cp313-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl (21.5 kB view details)

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

zlib_into-0.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_x86_64.whl (26.6 kB view details)

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

zlib_into-0.2-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.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_x86_64.whl (27.0 kB view details)

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

zlib_into-0.2-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.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_x86_64.whl (26.2 kB view details)

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

zlib_into-0.2-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.2.tar.gz.

File metadata

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

File hashes

Hashes for zlib_into-0.2.tar.gz
Algorithm Hash digest
SHA256 65fb4bd3f268caf0c97fd102b71cd6148436590c46fbf321323e818306248e59
MD5 353e58b80cd2150fe8daeea7793e45bf
BLAKE2b-256 86fa4c5f97ad53da40a37098877e44544db3b27eaf73c5912c9a2e70c5943f6d

See more details on using hashes here.

File details

Details for the file zlib_into-0.2-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.2-cp313-cp313t-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 88acd404401875d1dc7db6a623590c96cc368ff8d174c0d689f0629884b8ffc7
MD5 6d24f57fe348c6a3c6504683df1b5afa
BLAKE2b-256 90fd3c3f25187fc0dd328e7927839b5e8ded673bb9703c2984aae57a1ecd3c11

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zlib_into-0.2-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 de15f55652de9991db464e4b76b3a6cedbe0d63c9a30122b1048dc5e5cd6a870
MD5 7778d31f0f738623747966a74bfbcfb8
BLAKE2b-256 d7c70716b4ffb5d10465eca8c3cc814c83738046c8e059256ecc90b9508044a7

See more details on using hashes here.

File details

Details for the file zlib_into-0.2-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.2-cp313-cp313-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0b42c6db66d301f2a9c1819cc75c9f1ef802a871e2b8eb98b0a3831527cfa01c
MD5 dc53fd760ce06a317d6d3d83d9aacbbb
BLAKE2b-256 9f5ad6d443312fc52bc6428766820f15e654872280886aba80a0294008ffeb88

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zlib_into-0.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 55493209178e96f58987c06a300f820bb679b05510c0b9b7394e3166455d9f68
MD5 57118a4a2ea7d3e1c372ad15ce5c9b4a
BLAKE2b-256 fb730e7e166862e8523d7870a62ca952b708028d9692af82aeb357cc5eb4be72

See more details on using hashes here.

File details

Details for the file zlib_into-0.2-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.2-cp312-cp312-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 be5c1c7ab3db1ba12fa01a46095bd613ec704139329e5b5798b344e8a831be7c
MD5 4b0ad5d0b62cfd27ddf9f0a0fa8d0066
BLAKE2b-256 751826a67072ff48e6f8c0606f57cbb7591606cc45e555a6f1501e48ad8201c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zlib_into-0.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ace9f073d93d3a8ad2591ea8f87aac6926fc324eb4b8c950324381379e2dbaa9
MD5 3fb6882ca70ca9e1bee981796d9fb21d
BLAKE2b-256 02d928354a6a0bd8b979ea768db920f53d050b82b42fe83b43840ad3fc914db3

See more details on using hashes here.

File details

Details for the file zlib_into-0.2-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.2-cp311-cp311-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 2bef39e65d1e3f3262e2ad3d86fc16d573d0f71eb5e8e84a91669b8ca6e470fd
MD5 6d707d0ae5e9fa6a5655ff6ea8077693
BLAKE2b-256 8b42e56796995db426a26ba77fda7a7fd25c434ae12ff8bada8b3d70ded2f659

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zlib_into-0.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 0159d54ba064889c69f99b4195452719c5c7532955317d3875485e73c181599a
MD5 9238e864055f687c9ab178ce4fc771cf
BLAKE2b-256 feed1296955e20419700d54f7b6ad708579f821c7110c19c49d4889bb92469d9

See more details on using hashes here.

File details

Details for the file zlib_into-0.2-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.2-cp310-cp310-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 9860e852d966fc45d879febf9552ae7fded1ebc039ebe58fbedafbda37365627
MD5 cd95f75fe5dabbad85991a82bc5ebfb1
BLAKE2b-256 a0d203fad91afd58514a1dc25b8f42871b4282e9e94a4f6eb29ebe1533c7bd8d

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