mgzip
A multi-threading implementation of Python gzip module
What it is and what it does
mgzip is a multi-threaded implementation of Python's gzip module that parallelizes compression and decompression across CPU cores. It uses a block-indexed GZIP format (via the FEXTRA field defined in GZIP spec 4.3) to enable concurrent processing while remaining fully compatible with standard GZIP readers. The module replaces gzip's GzipFile class and open/compress/decompress functions with threaded equivalents.
The package is designed for scenarios where large files need fast compression or decompression on multi-core systems. It trades some compatibility (seek/tell not yet supported) for speed gains. The implementation is in Beta status and actively maintained, though the author notes that real-world performance depends on IO and Python interpreter limitations rather than pure CPU scaling.
Use it for:
- Compress large log files or data dumps quickly on multi-core servers before archival or transfer.
- Decompress GZIP archives in parallel to speed up data pipeline initialization on systems with spare CPU capacity.
- Replace standard gzip calls in existing code with minimal changes to gain multi-threaded performance.
- Process block-indexed GZIP files created by mgzip itself for faster random-access decompression.
- Reduce compression time in batch data processing workflows where IO is not the bottleneck.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
mgzip provides a drop-in replacement for Python's standard gzip module that uses multi-threading to compress and decompress files in parallel, compatible with standard GZIP format.
Yes, if you need faster GZIP compression/decompression on multi-core systems and can work around the missing seek/tell methods. Low install friction, no dependencies, MIT-licensed, and actively maintained. Not suitable if you rely on seek/tell or need production-grade stability—the package is still Beta.
Install
mgzip on PyPI
pip
pip install mgzipuv
uv add mgzippoetry
poetry add mgzipInstalling mgzip
Before you install
Low install friction with no runtime dependencies. Actively maintained as of 2026-02-28 with recent development activity.
License in practice
MIT License permits commercial and private use with minimal restrictions; suitable for most projects.
Quickstart
import mgzip
with mgzip.open("file.txt.gz", "wt", thread=8, blocksize=200000000) as f:
f.write("data")
with mgzip.open("file.txt.gz", "rt", thread=8) as f:
data = f.read()
Requires Python 3.8 or later; seek() and tell() are not yet supported.
Verify before relying
- Whether seek() and tell() methods will be implemented in future releases
- Real-world performance gains on systems with fewer than 24 CPU cores
- Compatibility with compressed files created by other multi-threaded gzip implementations
Package facts
| License | MIT License (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 167 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 74,775/month — #14,795 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mgzip-0.2.5-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 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
indexed-gzipProvides fast random access to gzip-compressed…
permissive · top 15,000 on PyPI
zopfliZopfli is a Python binding for Google's Zopfli…
permissive · top 1,000 on PyPI
zlib-ngProvides faster zlib and gzip compression and…
permissive · top 5,000 on PyPI
python-neo-lzfProvides fast compression and decompression of…
permissive · top 15,000 on PyPI
Flask-CompressFlask-Compress automatically compresses Flask…
permissive · top 5,000 on PyPI
xopenxopen provides a drop-in replacement for…
permissive · top 5,000 on PyPI
pyzstdProvides Python bindings to the Zstandard…
permissive · top 5,000 on PyPI