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

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

Built distributions (wheels)

Table of built distributions (wheels) for zlib-state 0.1.12
File
zlib_state-0.1.12-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.12-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
zlib_state-0.1.12-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.12-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
zlib_state-0.1.12-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.28+ x86-64, Linux glibc 2.17+ x86-64 Details
zlib_state-0.1.12-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
zlib_state-0.1.12-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.12-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
zlib_state-0.1.12-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.12-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
zlib_state-0.1.12-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.12-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
zlib_state-0.1.12-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: 240.9 kB

Release files / zlib_state-0.1.12.tar.gz

Download URL zlib_state-0.1.12.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ccbb06321daf165b022aa4d22d62effb7df76f55035d50bbe8b93696db416cf0
BLAKE2b-256 checksum
How to use checksums
53f2c1b3dfb76ff3eac8eb2a96eb1e8e05c13534c73f0d1d582dfadadb5a863a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

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

Download URL zlib_state-0.1.12-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
360054c4c640b4e74a807a5739bcf99451b410892f15723d4a1cb56352a43e54
BLAKE2b-256 checksum
How to use checksums
59a4f59dc9cbfc704cf5357bbc40d5ae0faf9358fe4b464276332e14df90e38e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

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

Download URL zlib_state-0.1.12-cp314-cp314-win_amd64.whl
Size 13.0 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
e3ed3230ae87770b3a809f987aa21d37a9063b102d3b9ef553fa871eb900638b
BLAKE2b-256 checksum
How to use checksums
d4b24980c6a03180c25e5ff10ba068fde1ec81a42728ea42f4dc3cae3f21a82b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

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

Download URL zlib_state-0.1.12-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
d743776b126e3bb7843f0f4fa428954ea16d9c29dfa933cf3e6085ef7ad6392c
BLAKE2b-256 checksum
How to use checksums
d0eafd777b721efb8df2a7910cdfa4c551c26c2a2667440148b03fb6227d10b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

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

Download URL zlib_state-0.1.12-cp313-cp313-win_amd64.whl
Size 12.8 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
6466325e9e20a7e30b0c0291024fef2cb80a534324393609b5b30db42c065d1b
BLAKE2b-256 checksum
How to use checksums
310d76a524ee21b62cecd00c469d5cf1093ec2310684ba9e2cdbf6d323681d0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

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

Download URL zlib_state-0.1.12-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
940674e4b4d6c4df7e3be75be48c6ad1f07c0f42cab2d0b5655f67b8f0532073
BLAKE2b-256 checksum
How to use checksums
6c09bafb78fbd0471aadeb96c4d79dc76b25c172153935563357b250c1f0d80b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

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

Download URL zlib_state-0.1.12-cp312-cp312-win_amd64.whl
Size 12.8 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
f1d38461b99af652575f50cfc334f0958dbfef541679199f4ef09877cf9509c4
BLAKE2b-256 checksum
How to use checksums
da7d47646b78823a16d6dc055b89a16bc04b80f9df979cfa0765470a2bed8417
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

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

Download URL zlib_state-0.1.12-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
91a0b6c7007ed4bd3162ac33114ceea62c28b24cd585efe3a10d2626576b445a
BLAKE2b-256 checksum
How to use checksums
bb20b26f462b948ea8e66f878502c9594a32eda4e8ad96d9943667f4fe0f7a91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

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

Download URL zlib_state-0.1.12-cp311-cp311-win_amd64.whl
Size 12.8 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
572a2a7984eba730cec204a906fb8d41fc1022b4818797c97c503acb213caef0
BLAKE2b-256 checksum
How to use checksums
2602fa5b6523a4cc3f52192a77a4f3d58563b200643d2408ed29e9808b17bd9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

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

Download URL zlib_state-0.1.12-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
1e37d5877273a7cfdc0f1a30c7efe50c95e617d1ff716ac88e2ea7589088a88e
BLAKE2b-256 checksum
How to use checksums
ccbfc1c1eaab3a127f58c27139901eaa5e16b779d4a6896719a09d239887d8da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

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

Download URL zlib_state-0.1.12-cp310-cp310-win_amd64.whl
Size 12.8 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
25ccf55445d9ebb6e3b89606a50da984a6f9a84ecfe52bb9841a925701ec5b53
BLAKE2b-256 checksum
How to use checksums
8d6ea10048a6246efd69b96eeadc46a9bd9172aea8562ce6e9009e3bffd49cfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.11

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

Download URL zlib_state-0.1.12-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
5ba18c237c0c8176c6a68965a990f32980cc734f51cee16c997fcf83908505ce
BLAKE2b-256 checksum
How to use checksums
6ca694a37b05fccfd3ff506535fb2537ea4e2a49e7eb8db761b4d826aa26bf79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / zlib_state-0.1.12-cp39-cp39-win_amd64.whl

Download URL zlib_state-0.1.12-cp39-cp39-win_amd64.whl
Size 12.8 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
d076cdbe4e47e8c796166b63c4ac5ab9d4f410020c1870b572815c2671fb7b51
BLAKE2b-256 checksum
How to use checksums
5521464e9aa02d23aae4abb21a269ebfabf92d9cdc4f5e2f1684860e07a67b03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.13

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

Download URL zlib_state-0.1.12-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
8a3981388a25877cfdd2b7f99d7c342f5fe09cb4b9a31f7e64a8f3d0bfae1f8b
BLAKE2b-256 checksum
How to use checksums
c9d0008b34ce142f8b3c1c3878cc1cf4a67aaeead085dcd6a822077045d7ed92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

0.1.12 This release

14 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