skillfed

mgzip

A multi-threading implementation of Python gzip module

mgzip v0.2.5 74.8K downloads/30d#14,795 on PyPI59
Permissive license MIT License Active released

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 mgzip

uv

uv add mgzip

poetry

poetry add mgzip

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTopic :: Software Development :: Libraries :: Python Modules

Tags

parallel gzip compressionmulti-threaded gzipfast gzip decompressionthreaded file compressionblock-indexed gzipconcurrent gzipgzip module replacement
compressionparallelizationgzip-compatible

More Python Modules packages