Skip to main content

Zstandard decompression in pure Python

Project description

fzstd - Python Edition

A Python translation of the high-performance Zstandard (de)compression library fzstd.

This is a pure Python implementation of Zstandard decompression that aims to be compatible with the original TypeScript version.

LLM-driven translation from TypeScript.

Installation

pip install fzstd

Or for development:

pip install -e .

Usage

Basic Decompression

import fzstd

# Decompress data
compressed_data = b'\x28\xb5\x2f\xfd...'  # zstandard compressed bytes
decompressed = fzstd.decompress(bytes(compressed_data))
text = decompressed.decode('utf-8')
print(text)

Streaming Decompression

For decompressing large files or data streams, use the Decompress class:

import fzstd

def handle_chunk(chunk: bytes, final: bool) -> None:
    print(f"Decompressed {len(chunk)} bytes")
    if final:
        print("Decompression complete")

# Create a decompressor with a handler
decompressor = fzstd.Decompress(handle_chunk)

# Push compressed data chunks
decompressor.push(chunk1)
decompressor.push(chunk2)
decompressor.push(final_chunk, final=True)

Limitations

  • Maximum backreference distance: 2^25 bytes (same as TypeScript version)
  • Not compatible with "ultra" compression levels (20+) for files > 32MB decompressed
  • And more!

Testing

Run the test suite:

python tests.py

Origin

This is a translation of the fzstd TypeScript library by Arjun Barrett (@101arrowz).

Original repository: https://github.com/101arrowz/fzstd

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

fzstd-0.1.1.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

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

fzstd-0.1.1-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file fzstd-0.1.1.tar.gz.

File metadata

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

File hashes

Hashes for fzstd-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9cef3f222d00c86a7b537c550de3c7121421439279e288cac4a856724dc6f7b6
MD5 19eef61cc4623bb2a71d5365fc26bdae
BLAKE2b-256 28a51f025b6f348dea0ef0176c567a94e2cda19332f64efb8526962f74b0b2e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for fzstd-0.1.1.tar.gz:

Publisher: pypi.yml on dholth/fzstdpy

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

File details

Details for the file fzstd-0.1.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for fzstd-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b9cf2677a0b792656bf8a0b1b2ef7117dfc293ab111b5a479edf7ae3d62c8f51
MD5 40511861c3038abb2c2794e4728c1668
BLAKE2b-256 6dc143c8aabdd73a6da9b493fb2b83a099f11a320a9f309c84ec07d31e01f97d

See more details on using hashes here.

Provenance

The following attestation bundles were made for fzstd-0.1.1-py3-none-any.whl:

Publisher: pypi.yml on dholth/fzstdpy

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