Skip to main content

Asynchronous gzip file reader/writer with aiocsv support.

Project description

aiogzip ⚡️

An asynchronous library for reading and writing gzip-compressed files.

License: MIT PyPI version Python 3.8-3.14 Tests Coverage Documentation

aiogzip provides a fast, simple, and asyncio-native interface for handling .gz files, making it a useful complement to Python's built-in gzip module for asynchronous applications.

🚀 Read the Documentation

Features

  • Truly Asynchronous: Built with asyncio and aiofiles.
  • High-Performance: Optimized buffer handling for fast I/O.
  • Drop-in Replacement: Mimics gzip.open() with async seek, tell, peek, and readinto support; verified against tarfile-style access patterns and aiocsv workflows.
  • Reproducible Archives: Control gzip mtime and embedded filenames.
  • Type-Safe: Distinct AsyncGzipBinaryFile and AsyncGzipTextFile.
  • aiocsv Ready: Seamless integration for CSV pipelines.
  • Predictable Performance: Backward seeks rewind the stream and re-decompress data (same as gzip.GzipFile), so treat random access as O(n) and prefer forward-only patterns when possible.

Quickstart

pip install aiogzip
import asyncio
from aiogzip import AsyncGzipFile

async def main():
    # Write
    async with AsyncGzipFile("file.gz", "wb") as f:
        await f.write(b"Hello, async world!")

    # Read
    async with AsyncGzipFile("file.gz", "rb") as f:
        print(await f.read())

asyncio.run(main())

# Deterministic metadata
async with AsyncGzipFile(
    "dataset.gz", "wb", mtime=0, original_filename="dataset.csv"
) as f:
    await f.write(b"stable bytes")

Performance

  • Text I/O: Often ~2-3x faster than standard gzip in bulk text workflows.
  • Binary I/O: Typically near parity for bulk reads/writes, and can be slower for very small chunk sizes.
  • Concurrency: Non-blocking I/O can improve throughput in latency-bound multi-file workloads.
  • Memory: Optimized buffer management for stable memory usage.
  • JSONL: For large gzipped JSONL files, prefer AsyncGzipTextFile(..., newline="\n", chunk_size=512 * 1024) to reduce line-iteration overhead.

See the Performance Guide for detailed benchmarks.

Contributing

See CONTRIBUTING.md for development instructions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiogzip-1.3.3.tar.gz (49.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiogzip-1.3.3-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file aiogzip-1.3.3.tar.gz.

File metadata

  • Download URL: aiogzip-1.3.3.tar.gz
  • Upload date:
  • Size: 49.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aiogzip-1.3.3.tar.gz
Algorithm Hash digest
SHA256 d2ac772367cfec69db9f19ffdf21c99e8b933f6eca9b247543a8adfa8df8726b
MD5 a26c78a8b801866355318d5213a5a29b
BLAKE2b-256 8ef96d160a3a7f45c4fc98b6ef4b2075527cb3d78e96862c19abc122de0f51fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiogzip-1.3.3.tar.gz:

Publisher: publish.yml on geoff-davis/aiogzip

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiogzip-1.3.3-py3-none-any.whl.

File metadata

  • Download URL: aiogzip-1.3.3-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aiogzip-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9a7e3b34d602124b8728ff6edc83b6549eac07e3767a54fbbfa79661bd593ddb
MD5 f2b0698619c8d2ea494398245293eef3
BLAKE2b-256 fc1c0c13878a6432d0fe4af7629713c47a039e8827e6a87f2de8a5e16e5d1433

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiogzip-1.3.3-py3-none-any.whl:

Publisher: publish.yml on geoff-davis/aiogzip

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page