Python 3.14+compression.zstdterm
compression.zstd.Strategy
compression parameters
An enum of zstd match-finding strategies from fast to btultra2; the value for the CompressionParameter.strategy parameter.
Syntax
options={CompressionParameter.strategy: Strategy.btopt}
It is an ordered IntEnum: the larger the value, the slower and denser, so Strategy.btultra2 > Strategy.fast is a meaningful comparison. The compression level already picks a strategy, so setting one by hand is rarely needed, and then the level also goes into options rather than the level argument. New libzstd versions may add strategies.
Examples
# Python 3.14+
from compression import zstd # → ? нужна сборка CPython с libzstd
S, P = zstd.Strategy, zstd.CompressionParameter
print(S.btultra2 > S.fast, S(5).name) # → True lazy2
data = b'hello zstd ' * 100
opts = {P.compression_level: 19, P.strategy: S.btultra2}
print(zstd.decompress(zstd.compress(data, options=opts)) == data) # → True
See also
Open in the full glossarydocs.python.orgReport an inaccuracy