Skip to main content

zlib-state

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

Install

From PyPi:

pip install zlib-state

From source:

pip install .

Tested on Ubuntu/macOs/Windows with Python 3.7-3.12.

GzipStateFile

Wraps Decompressor as a buffered reader.

Based on my benchmarking, this is somewhat slower than python's gzip.

A typical usage pattern looks like:

import zlib_state

TARGET_LINE = 5000 # pick back up after around the 5,000th line
# Specify keep_last_state=True to tell object to grab and keep the state and pos after each block
with zlib_state.GzipStateFile('testdata/frankenstein.txt.gz', keep_last_state=True) as f:
    for i, line in enumerate(f):
        if i == TARGET_LINE:
            state, pos = f.last_state, f.last_state_pos

with zlib_state.GzipStateFile('testdata/frankenstein.txt.gz') as f:
    f.zseek(pos, state)
    remainder = f.read()

Decompressor

Very basic decompression object that's picky and unforgiving.

Based on my benchmarking, this can iterate over gzip files faster than python's gzip.

A typical usage pattern looks like:

import zlib_state

decomp = zlib_state.Decompressor(32 + 15) # from zlib; 32 indicates gzip header, 15 window size
block_count = 0
with open('testdata/frankenstein.txt.gz', 'rb') as f:
    while not decomp.eof():
        needed_input = decomp.needs_input()
        if needed_input > 0:
            # decomp needs more input, and it tells you how much.
            decomp.feed_input(f.read(needed_input))
        # next_chunk may be empty (e.g., if finished with gzip headers) or may contain data.
        # It sends as much as it has left in its output buffer, or asks zlib to continue.
        next_chunk = decomp.read() # you can also pass a maximum size to take and/or a buffer to write to
        if decomp.block_boundary():
            block_count += 1
            # When it reaches the end of a deflate block, it always stops. At these times, you can grab the state
            # if you wish.
            if block_count == 4: # resume after the 4th block
                state = decomp.get_state() # includes zdict, bits, byte -- everything it needs to resume from pos
                pos = decomp.total_in() # the current position in the binary file to resume from
    print(f'{block_count} blocks processed')
    # resume from somewhere in the file. Only possible spots are the block boundaries, given the state
    f.seek(pos)
    decomp = zlib_state.Decompressor(-15) # from zlib; 15 window size, negative means no headers
    decomp.set_state(*state)
    while not decomp.eof():
        needed_input = decomp.needs_input()
        if needed_input > 0:
            # decomp needs more input, and it tells you how much.
            decomp.feed_input(f.read(needed_input))
        next_chunk = decomp.read()

Metadata

Release files for zlib-state 0.1.13

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-state 0.1.13
File Size Uploaded
zlib_state-0.1.13.tar.gz 9.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for zlib-state 0.1.13
File
zlib_state-0.1.13-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.15 CPython 3.15 free-threading Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
zlib_state-0.1.13-cp315-cp315-win_amd64.whl CPython 3.15 CPython 3.15 Windows x86-64 Details
zlib_state-0.1.13-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.15 CPython 3.15 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details
zlib_state-0.1.13-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
zlib_state-0.1.13-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
zlib_state-0.1.13-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
zlib_state-0.1.13-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
zlib_state-0.1.13-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
zlib_state-0.1.13-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
zlib_state-0.1.13-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
zlib_state-0.1.13-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
zlib_state-0.1.13-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
zlib_state-0.1.13-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
zlib_state-0.1.13-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
zlib_state-0.1.13-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details

Total release size: 283.4 kB

Release files / zlib_state-0.1.13.tar.gz

Download URL zlib_state-0.1.13.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bcc062d5355dd171bd07c9a987ce1bd8af19decd9f640b374cf7860440346660
BLAKE2b-256 checksum
How to use checksums
dea43045a5f81e837aad6df487bf18c598db2aa15bf70f9f2c0b361d8234b363
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / zlib_state-0.1.13-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL zlib_state-0.1.13-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 24.3 kB
Tags CPython 3.15 CPython 3.15 free-threading Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
682d3dd1c4240e8fe44d18a0cb7e50b091ded640dfadd7ebb3740255e5c106a2
BLAKE2b-256 checksum
How to use checksums
4ad1468b392140259b523747f581b43271dfaef60d4fab09749fe3b4d6be3b7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / zlib_state-0.1.13-cp315-cp315-win_amd64.whl

Download URL zlib_state-0.1.13-cp315-cp315-win_amd64.whl
Size 12.3 kB
Tags CPython 3.15 Windows x86-64
SHA-256 checksum
How to use checksums
27223d04a977032e48486ba9ea7ee2af7a68cd42e8f28aae05843cbee5a46ab7
BLAKE2b-256 checksum
How to use checksums
c37b58f226a414eb99f2464af7d632500157874abffc4b127af2c2ddf8a9bf22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Release files / zlib_state-0.1.13-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL zlib_state-0.1.13-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 22.2 kB
Tags CPython 3.15 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
5dd7145c0ed2f0afc297d5e88a6f754649a08b71b742a4b8ec7e5d182e170c94
BLAKE2b-256 checksum
How to use checksums
ac7e740d3fc0bf7cc9fd6e533c19927b6ae0b5df566feab0d856bc46dec1245e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / zlib_state-0.1.13-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL zlib_state-0.1.13-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 24.1 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
2351b704a77d7aea869ccc7ebbf79522d7532434b65e7de07105dd6707a98f70
BLAKE2b-256 checksum
How to use checksums
52552d154773482ecb5e55adea100abe859796ef83e008385e239a51e7394023
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / zlib_state-0.1.13-cp314-cp314-win_amd64.whl

Download URL zlib_state-0.1.13-cp314-cp314-win_amd64.whl
Size 12.3 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
4bc1d9d13ce31a156f7d31c48f292eb13e9fdf91218c5e5065e2eb79f3a5e792
BLAKE2b-256 checksum
How to use checksums
77470173bf86d95157deaf1e9a2040c24f7698218b5ff6f399e5d205f3ec0ca8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / zlib_state-0.1.13-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL zlib_state-0.1.13-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 22.1 kB
Tags CPython 3.14 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
dfd39cf27883d8548800a59291387c79ae036923e263b4f23663e0311bfc02ce
BLAKE2b-256 checksum
How to use checksums
86b889ea69d304ece1d0a689fe6b2a9c875890fbbafb259a71f9c79b6a6a2bc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / zlib_state-0.1.13-cp313-cp313-win_amd64.whl

Download URL zlib_state-0.1.13-cp313-cp313-win_amd64.whl
Size 12.1 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
8b6d1100c3bbadb57592bc9722a7934f304588c9776da7da5d8681b22b563e7a
BLAKE2b-256 checksum
How to use checksums
8772066be9d8df27f6d7b9d5dbe3c4c4ffd39ba40fb9937a8fec4ec2fa28cf29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / zlib_state-0.1.13-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL zlib_state-0.1.13-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 22.0 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
0da2c17f4165f0c9ce282d25466a442326bd518c271a1d935b0ed374d878e5f8
BLAKE2b-256 checksum
How to use checksums
9245706a73216d14db1df8a3192484ae4aab891436a1a557035c852926b20c37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / zlib_state-0.1.13-cp312-cp312-win_amd64.whl

Download URL zlib_state-0.1.13-cp312-cp312-win_amd64.whl
Size 12.1 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
8e53f43db92e7b5448cc4ec8b50de3389ce96d0863f36bda1fca25fae5c3bc06
BLAKE2b-256 checksum
How to use checksums
57ad213cf604a31b75ceb6f716c2750a36bde0826a3beb926ba1564566884819
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / zlib_state-0.1.13-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL zlib_state-0.1.13-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 22.0 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
72878ac873ac7b78df40e675b9e9eb2f5fb9a97429f40eb45da3bb31f163bd9d
BLAKE2b-256 checksum
How to use checksums
dd62ac364a3949cd2632ef9c97359ae22dbb118711c749cb4297fd6acfad11cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / zlib_state-0.1.13-cp311-cp311-win_amd64.whl

Download URL zlib_state-0.1.13-cp311-cp311-win_amd64.whl
Size 12.0 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
8424076431e73f9a90a53aec64d2f35bebf77e86bdda0f53d2c04e5256655f9c
BLAKE2b-256 checksum
How to use checksums
19f3404436910af13bde7a6d290176c445b7072d95f87fc2d7d2a3edb1d1b89d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / zlib_state-0.1.13-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL zlib_state-0.1.13-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 21.5 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
fbe4ab510c41ac967c62fa0c9c5c2b6147c4e31f744e1f92001deaf63a1a990c
BLAKE2b-256 checksum
How to use checksums
00d52c0077d7b56a6bf670c832c45afd99b2a924a8bca06311cf1599c8751579
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / zlib_state-0.1.13-cp310-cp310-win_amd64.whl

Download URL zlib_state-0.1.13-cp310-cp310-win_amd64.whl
Size 12.0 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
edd677aae2565a07b81fb0112225661514393d2d6e97adca06bb07ac28b28632
BLAKE2b-256 checksum
How to use checksums
8feaa5ac8982ad518dac3f5983ba09f87d02b1ddf15776ef34e5ed584fe4e395
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release files / zlib_state-0.1.13-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL zlib_state-0.1.13-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 21.4 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
df1bbeaa86d4eab5fbd778920111be90cb249ae112dfa99b54f0224759da86c1
BLAKE2b-256 checksum
How to use checksums
d01d2b83791c47b2520dc0f409e78abb4602d4b65f6d9b80ce2d02efd05cdc8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / zlib_state-0.1.13-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL zlib_state-0.1.13-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 21.3 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
d200e9e1c9f32ebac4412dfe855020e9f09987b72c6b1af1c822db0932552bba
BLAKE2b-256 checksum
How to use checksums
7a11c8a0385276b38aa306b7aabcf69bdb412c16dc23bb837fd217c06d7318f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release history Release notifications | RSS feed

This release

0.1.13 This release

16 release files

0.1.8

6 release files

0.1.7

6 release files

0.1.6

27 release files

0.1.4

6 release files

0.1.3

29 release files

0.1.2

25 release files

0.1.1

25 release files

0.0.1

1 release file

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