Zstandard Python Bindings

raw JSON →
0.25.0 verified Tue May 12 auth: no python install: verified quickstart: verified

Python bindings for the Zstandard compression library, providing high compression ratios and fast decompression speeds. Current version: 0.25.0. Released on a regular basis with active maintenance.

pip install zstandard
error ModuleNotFoundError: No module named 'zstandard'
cause The `zstandard` package is not installed in the current Python environment or is not accessible on the Python path.
fix
pip install zstandard
error ERROR: Could not build wheels for zstandard
cause The system lacks necessary C/C++ build tools (like a compiler) required to compile the `zstandard` C extensions from source.
fix
Install the appropriate build tools for your operating system (e.g., build-essential on Debian/Ubuntu, Xcode command line tools on macOS, or Visual C++ build tools on Windows) before running pip install zstandard.
error zstandard.ZstdError: Decompression error: Frame content corrupted
cause The input data is corrupted, incomplete, or not a valid Zstandard frame, preventing successful decompression.
fix
Verify the integrity and completeness of the compressed input data. Ensure that the data was indeed compressed using Zstandard and that any required dictionaries are correctly applied during decompression.
error AttributeError: module 'zstandard' has no attribute 'compress'
cause The `zstandard` module does not expose top-level `compress` or `decompress` functions directly; these operations are performed via instances of `ZstdCompressor` or `ZstdDecompressor`.
fix
Create an instance of the ZstdCompressor or ZstdDecompressor class to perform compression/decompression, e.g., cctx = zstandard.ZstdCompressor(); compressed_data = cctx.compress(data).
breaking Support for Python 3.8 has been dropped; Python 3.9 is now the minimum supported version.
fix Upgrade to Python 3.9 or later.
deprecated The 'manylinux2010' wheel format is no longer supported; consider using 'manylinux2014' or 'manylinux2010' wheels.
fix Update wheel distribution to 'manylinux2014' or 'manylinux2010'.
python os / libc status wheel install import disk
3.10 alpine (musl) - - 0.02s 32.5M
3.10 slim (glibc) - - 0.02s 41M
3.11 alpine (musl) - - 0.03s 34.3M
3.11 slim (glibc) - - 0.02s 43M
3.12 alpine (musl) - - 0.01s 26.2M
3.12 slim (glibc) - - 0.00s 35M
3.13 alpine (musl) - - 0.01s 25.8M
3.13 slim (glibc) - - 0.01s 35M
3.9 alpine (musl) - - 0.02s 32.0M
3.9 slim (glibc) - - 0.02s 41M

Basic usage example demonstrating compression and decompression with zstandard.

import zstandard

# Compress data
compressor = zstandard.ZstdCompressor()
compressed_data = compressor.compress(b'Hello, world!')

# Decompress data
decompressor = zstandard.ZstdDecompressor()
decompressed_data = decompressor.decompress(compressed_data)
print(decompressed_data.decode())  # Outputs: Hello, world!