Python Glossary Русский

Python 3.14+compression.zstdfunction

compression.zstd.get_frame_info()

frame information

Reads a zstd frame header and returns FrameInfo: the original size (if recorded) and the id of the dictionary needed to decompress.

Syntax

compression.zstd.get_frame_info(frame_buffer) -> FrameInfo

It does not decompress or verify integrity, it only reads the header. decompressed_size can be None: streaming compression (ZstdCompressor without set_pledged_input_size, ZstdFile) does not know the size up front, so never size a buffer from this field. A non-zero dictionary_id tells you right away that decompress will fail without a dictionary. Garbage instead of a frame raises ZstdError.

Examples

# Python 3.14+
from compression import zstd  # → ? нужна сборка CPython с libzstd
data = b'hello zstd ' * 100
print(zstd.get_frame_info(zstd.compress(data)))  # → FrameInfo(decompressed_size=1100, dictionary_id=0)
comp = zstd.ZstdCompressor()
stream = comp.compress(data) + comp.flush()
print(zstd.get_frame_info(stream).decompressed_size)  # → None — потоку размер неизвестен

See also

Open in the full glossarydocs.python.orgReport an inaccuracy