skillfed

zlib-state

Low-level interface to the zlib library that enables capturing the decoding state

zlib-state v0.1.12 221.5K downloads/30d#9,276 on PyPI2
Permissive license Active released

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-state

uv

uv add zlib-state

poetry

poetry add zlib-state

Installing 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

License :: OSI Approved :: MIT License

Tags

gzip decompression state captureresumable gzip file readingzlib state managementdeflate block boundariesstreaming gzip decompressionzlib decoder statepartial gzip decompression
compressionstreamingcheckpointing

More Software Development packages