Supported Compression Algorithms
Compressed buffers accept registered compression method names through the
compression_method argument.
Implemented compression methods
none— No compression other than casting toelem_typeand storing asbytes.rle— Vectorized run-length encoding for compression.rle-jit— JIT-compiled version ofrle; uses the numba library.gzip— Built-in gzip compression via Python’sgzipmodule.igzip— Intel-accelerated variant viaisal.igzip; uses python-isal.zstd— Zstandard compression via python-zstd. (Recommended)lz4-frame— LZ4 (frame format) compression via python-lz4.lz4-block— LZ4 (block format) compression via python-lz4.
The recommended starting point from the Benchmarks is zstd-3. For very
sparse or palette-like observations, rle and rle-jit are worth testing as
well.
Compression levels
gzipsupports levels0through9;0is no compression,1is least compression.igzipsupports levels0through3;0is least compression.zstdsupports standard levels1through22and ultra-fast levels-100through-1;-100is fastest and22is slowest.lz4-framesupports standard levels0through16; negative levels map to an acceleration factor.lz4-blocksupports three modes split by sign of the level:1through12—high_compressionmode.0—defaultmode.Negative levels —
fastmode; the level maps to an acceleration factor.
Shorthand method names
Level suffixes can be appended as shorthand strings (for lz4 methods, a
/ before the level is required):
pattern = ^((?:[A-Za-z]+)|(?:[\w\-]+/))(\-?[0-9]+)$
Examples:
igzip3=igzip/3= igzip level 3zstd-5=zstd/-5= zstd level -5lz4-frame/5= lz4-frame level 5
In Python:
compression_method = "zstd-3"
compression_method = "igzip3"
compression_method = "lz4-frame/5"
Optional backends
Install optional extras for faster or additional compression implementations:
pip install "sb3-extra-buffers[fast]"
The fast extra installs isal, numba, zstd, and lz4.