{"id":4785,"library":"stream-inflate","title":"Stream Inflate","description":"stream-inflate is a Python library, currently at version 0.0.43, designed to uncompress DEFLATE and DEFLATE64 streams. It is written in pure Python but is compiled with Cython for performance. The library maintains an active development status with frequent, small releases addressing new Python versions and bug fixes.","status":"active","version":"0.0.43","language":"en","source_language":"en","source_url":"https://github.com/michalc/stream-inflate","tags":["compression","deflate","stream","cython"],"install":[{"cmd":"pip install stream-inflate","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"stream_inflate","correct":"from stream_inflate import stream_inflate"},{"symbol":"stream_inflate64","correct":"from stream_inflate import stream_inflate64"}],"quickstart":{"code":"import os\nfrom stream_inflate import stream_inflate\n\ndef get_compressed_data_example():\n    # This is a dummy example. In a real scenario, this would yield bytes\n    # from a DEFLATE-compressed source (e.g., network stream, file).\n    # For demonstration, we'll use a pre-compressed string.\n    # 'x\\x9c\\xcbH\\xcd\\xc9\\xc9W(\\xcf/\\xcaIQ\\x04\\x00\\x1a\\x07\\x04\\x16' is DEFLATE for 'Hello, world!'\n    yield b'x\\x9c\\xcbH\\xcd\\xc9\\xc9W(\\xcf/\\xcaIQ\\x04\\x00\\x1a\\x07\\x04\\x16'\n\n# To uncompress a DEFLATE stream\nuncompressed_chunks_iterator, _ = stream_inflate(get_compressed_data_example())\nfor chunk in uncompressed_chunks_iterator:\n    print(f\"Received uncompressed chunk: {chunk.decode()}\")\n\n# Example for a real network stream (requires httpx, not a direct dependency of stream-inflate)\n# import httpx\n# def compressed_chunks_from_url():\n#     with httpx.stream('GET', 'https://www.example.com/my_deflate_file') as r:\n#         yield from r.iter_raw(chunk_size=65536)\n#\n# For uncompressed_chunk in stream_inflate(compressed_chunks_from_url()):\n#     print(uncompressed_chunk)","lang":"python","description":"This quickstart demonstrates how to use `stream_inflate` to decompress a DEFLATE stream. The `stream_inflate` function takes an iterable that yields bytes of the compressed stream and returns a tuple. The first element of the tuple is an iterator yielding uncompressed byte chunks. The second element is a callable that returns the index of the end of the compressed stream, relative to the last data chunk consumed, useful for streams with trailing data."},"warnings":[{"fix":"Upgrade Python to 3.7.7 or newer.","message":"Python 3.6 support was officially dropped in version 0.0.42. Users on Python 3.6 or older must upgrade their Python environment or remain on an older version of stream-inflate.","severity":"breaking","affected_versions":"<0.0.42"},{"fix":"Upgrade to stream-inflate 0.0.37 or later.","message":"Versions prior to 0.0.37 contained a bug that could lead to an infinite loop when decompressing certain DEFLATE streams. It is highly recommended to upgrade to version 0.0.37 or newer to avoid this issue.","severity":"gotcha","affected_versions":"<0.0.37"},{"fix":"Refer to the official documentation for the specific usage pattern that fits your streaming requirements, particularly if you need to manage stream state or handle trailing data.","message":"The `stream_inflate` function has two primary usage patterns. The quickstart demonstrates `stream_inflate(iterable_of_chunks)`, which returns a tuple `(uncompressed_iterator, get_end_index)`. An alternative, more advanced pattern shown in PyPI documentation is to call `stream_inflate()` without arguments to get a tuple of functions `(uncompressed_chunks_callable, is_done_callable, num_bytes_unconsumed_callable)` for fine-grained control over stream processing. Ensure you use the correct pattern for your needs.","severity":"gotcha","affected_versions":">=0.0.37"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}