zlib-state
Low-level interface to the zlib library that enables capturing the decoding state
What it is and what it does
zlib-state wraps the zlib library to expose decompression state at deflate block boundaries, allowing you to pause and resume gzip decompression from a known position. It provides two main interfaces: Decompressor for fine-grained control over the decompression stream, and GzipStateFile for a file-like reader that tracks state after each block. The package trades some simplicity for the ability to checkpoint progress mid-file, which is useful when processing large compressed files where you need to pause, save position, and resume later.
The library is a thin binding over zlib's internal state machine and requires careful use—decompression can only resume at block boundaries, not arbitrary byte positions. It has no runtime dependencies and is distributed as precompiled wheels for modern Python versions on Linux and Windows, making installation straightforward on supported platforms.
Use it for:
- Pause and resume decompression of large gzip files across application restarts or crashes.
- Implement checkpointing in data pipelines that process compressed logs or archives incrementally.
- Build fault-tolerant streaming decompressors that can recover from interruption at known block boundaries.
- Optimize gzip iteration performance when standard library decompression is a bottleneck.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides low-level access to zlib decompression with the ability to capture and restore decoder state at block boundaries, enabling resumable gzip file reading.
Yes, if you need to checkpoint gzip decompression progress or require faster iteration over compressed streams. The permissive MIT license and active maintenance make it low-risk. Not necessary if you only need standard gzip reading or cannot work within the block-boundary constraint.
Install
zlib-state on PyPI
pip
pip install zlib-stateuv
uv add zlib-statepoetry
poetry add zlib-stateInstalling zlib-state
Before you install
Medium install friction due to compiled wheels; prebuilt binaries available for Python 3.9–3.14 on Linux and Windows. Active maintenance with recent release.
License in practice
MIT license (permissive); no restrictions on commercial or private use.
Quickstart
import zlib_state
# Capture state at block boundary
decomp = zlib_state.Decompressor(32 + 15)
with open('file.gz', 'rb') as f:
while not decomp.eof():
if decomp.needs_input() > 0:
decomp.feed_input(f.read())
decomp.read()
if decomp.block_boundary():
state = decomp.get_state()
pos = decomp.total_in()
break
Requires Python 3.9 or later; state capture only works at deflate block boundaries, not arbitrary file positions.
Verify before relying
- Whether performance advantage over standard gzip holds across different file sizes and compression levels.
- Compatibility with all gzip variants and edge cases (e.g., concatenated gzip streams).
- Memory overhead of storing state objects for large files.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 122 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 221,482/month — #9,276 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: zlib_state-0.1.12-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; zlib_state-0.1.12-cp310-cp310-win_amd64.whl; zlib_state-0.1.12-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; zlib_state-0.1.12-cp311-cp311-win_amd64.whl; zlib_state-0.1.12-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; zlib_state-0.1.12-cp312-cp312-win_amd64.whl; zlib_state-0.1.12-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; zlib_state-0.1.12-cp313-cp313-win_amd64.whl; zlib_state-0.1.12-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; zlib_state-0.1.12-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; zlib_state-0.1.12-cp314-cp314-win_amd64.whl; zlib_state-0.1.12-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; zlib_state-0.1.12-cp39-cp39-win_amd64.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
zlib-ngProvides faster zlib and gzip compression and…
permissive · top 5,000 on PyPI
deflateThin Python wrapper around libdeflate for fast…
permissive · top 15,000 on PyPI
zopfliZopfli is a Python binding for Google's Zopfli…
permissive · top 1,000 on PyPI
zipfile-deflate64Enables extraction of Deflate64-compressed ZIP…
permissive · top 5,000 on PyPI
python-neo-lzfProvides fast compression and decompression of…
permissive · top 15,000 on PyPI
pgzippgzip is a multi-threaded gzip implementation…
permissive · top 15,000 on PyPI
gzip-streamWraps streams to compress data on-the-fly using…
permissive · top 15,000 on PyPI
py7zrpy7zr is a pure-Python library for reading,…
copyleft · top 5,000 on PyPI
pyppmdCompresses and decompresses data using the PPMd…
copyleft · top 5,000 on PyPI
indexed-gzipProvides fast random access to gzip-compressed…
permissive · top 15,000 on PyPI