Python Glossary Русский

Python 3.14+compression.zstdterm

compression.zstd.ZstdDecompressor

incremental compression

An incremental Zstandard decompressor for data that arrives in parts. It handles exactly one frame.

Syntax

d = compression.zstd.ZstdDecompressor(zstd_dict=None, options=None); d.decompress(data, max_length=-1)

Unlike the decompress function, the object decompresses one frame: whatever follows its end lands in unused_data, and another call once eof=True raises EOFError, so the next frame needs a new object. max_length limits output per call (a bomb guard); the rest comes out on later calls, and needs_input=False says not to feed new data yet.

Examples

# Python 3.14+
from compression import zstd  # → ? нужна сборка CPython с libzstd
frame = zstd.compress(b'hello zstd ' * 100)
d = zstd.ZstdDecompressor()
print(len(d.decompress(frame + b'tail')), d.eof, d.unused_data)  # → 1100 True b'tail'
d.decompress(frame)  # → EOFError: Already at the end of a Zstandard frame.
# Python 3.14+
from compression import zstd  # → ? нужна сборка CPython с libzstd
frame = zstd.compress(b'hello zstd ' * 100)
d = zstd.ZstdDecompressor()
print(d.decompress(frame, max_length=10), d.needs_input)  # → b'hello zstd' False
print(len(d.decompress(b'')), d.eof)  # → 1090 True

See also

Common errors

Open in the full glossarydocs.python.orgReport an inaccuracy