Python Glossary Русский

Python 3.14+compression.zstdfunction

compression.zstd.get_frame_size()

frame information

Returns the size of the first zstd frame in a buffer, including the header and checksum, so concatenated frames can be split.

Syntax

compression.zstd.get_frame_size(frame_buffer) -> int

The buffer must start at the beginning of a frame and hold it entirely; anything after the frame (the next frame or stray bytes) is ignored and not counted. It is the way to take a stream of frames apart one by one, whereas decompress joins them all into one. The function is in the module's __all__ but not described on the documentation page; details live only in its docstring.

Examples

# Python 3.14+
from compression import zstd  # → ? нужна сборка CPython с libzstd
stream = zstd.compress(b'one') + zstd.compress(b'two')
n = zstd.get_frame_size(stream)
print(zstd.decompress(stream[:n]), zstd.decompress(stream[n:]))  # → b'one' b'two'
print(zstd.decompress(stream))  # → b'onetwo'

See also

Open in the full glossarydocs.python.orgReport an inaccuracy