ZstdCompressionParameters
¶
Zstandard offers a high-level compression level that maps to lower-level compression parameters. For many consumers, this numeric level is the only compression setting you’ll need to touch.
But for advanced use cases, it might be desirable to tweak these lower-level settings.
The ZstdCompressionParameters
type represents these low-level compression
settings.
-
class
zstandard.
ZstdCompressionParameters
(format=0, compression_level=0, window_log=0, hash_log=0, chain_log=0, search_log=0, min_match=0, target_length=0, strategy=-1, write_content_size=1, write_checksum=0, write_dict_id=0, job_size=0, overlap_log=-1, force_max_window=0, enable_ldm=0, ldm_hash_log=0, ldm_min_match=0, ldm_bucket_size_log=0, ldm_hash_rate_log=-1, threads=0)¶ Low-level zstd compression parameters.
This type represents a collection of parameters to control how zstd compression is performed.
Instances can be constructed from raw parameters or derived from a base set of defaults specified from a compression level (recommended) via
ZstdCompressionParameters.from_level()
.>>> # Derive compression settings for compression level 7. >>> params = zstandard.ZstdCompressionParameters.from_level(7)
>>> # With an input size of 1MB >>> params = zstandard.ZstdCompressionParameters.from_level(7, source_size=1048576)
Using
from_level()
, it is also possible to override individual compression parameters or to define additional settings that aren’t automatically derived. e.g.:>>> params = zstandard.ZstdCompressionParameters.from_level(4, window_log=10) >>> params = zstandard.ZstdCompressionParameters.from_level(5, threads=4)
Or you can define low-level compression settings directly:
>>> params = zstandard.ZstdCompressionParameters(window_log=12, enable_ldm=True)
Once a
ZstdCompressionParameters
instance is obtained, it can be used to configure a compressor:>>> cctx = zstandard.ZstdCompressor(compression_params=params)
Some of these are very low-level settings. It may help to consult the official zstandard documentation for their behavior. Look for the
ZSTD_p_*
constants inzstd.h
(https://github.com/facebook/zstd/blob/dev/lib/zstd.h).-
chain_log
¶
-
compression_level
¶
-
enable_ldm
¶
-
estimated_compression_context_size
()¶ Estimated size in bytes needed to compress with these parameters.
-
force_max_window
¶
-
format
¶
-
static
from_level
(level, source_size=0, dict_size=0, **kwargs)¶ Create compression parameters from a compression level.
Parameters: - level – Integer compression level.
- source_size – Integer size in bytes of source to be compressed.
- dict_size – Integer size in bytes of compression dictionary to use.
Returns:
-
hash_log
¶
-
job_size
¶
-
ldm_bucket_size_log
¶
-
ldm_hash_log
¶
-
ldm_hash_rate_log
¶
-
ldm_min_match
¶
-
min_match
¶
-
overlap_log
¶
-
search_log
¶
-
strategy
¶
-
target_length
¶
-
threads
¶
-
window_log
¶
-
write_checksum
¶
-
write_content_size
¶
-
write_dict_id
¶
-