https://github.com/dholth/fzstdpy
Zstandard decompression in pure Python
https://github.com/dholth/fzstdpy
Last synced: 3 days ago
JSON representation
Zstandard decompression in pure Python
- Host: GitHub
- URL: https://github.com/dholth/fzstdpy
- Owner: dholth
- License: other
- Created: 2026-05-19T17:16:23.000Z (29 days ago)
- Default Branch: main
- Last Pushed: 2026-05-19T17:22:26.000Z (29 days ago)
- Last Synced: 2026-05-21T09:46:23.048Z (27 days ago)
- Language: Python
- Size: 12.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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