Metadata-Version: 2.4
Name: fzstd
Version: 0.1.1
Summary: Zstandard decompression in pure Python
Project-URL: Repository, https://github.com/dholth/fzstdpy
Author: Arjun Barrett
Author-email: Daniel Holth <dholth@fastmail.fm>
License: MIT
License-File: LICENSE
Keywords: compression,decompression,fast,tiny,zstandard,zstd
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.11
Description-Content-Type: text/markdown

# fzstd - Python Edition

A Python translation of the high-performance Zstandard (de)compression library [fzstd](https://github.com/101arrowz/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

```bash
pip install fzstd
```

Or for development:

```bash
pip install -e .
```

## Usage

### Basic Decompression

```python
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:

```python
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:

```bash
python tests.py
```

## Origin

This is a translation of the fzstd TypeScript library by Arjun Barrett ([@101arrowz](https://github.com/101arrowz)).

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

