compress¶
- tinycompress.lzssw.compress(data, ringsize=4096, maxmatchlen=16, commonbyte=32)[source]¶
Compresses data using the LZSSW algorithm.
This is a convenience function that creates a compressor with specified parameters, compresses the data, and returns the result.
- Parameters:
data (
Union[bytes,bytearray,memoryview,Iterable[int]]) – Data to compress.ringsize (
int) – Size of the ring buffer, must be between RING_SIZE_MIN and RING_SIZE_MAX. Larger sizes allow finding matches further back.maxmatchlen (
int) – Maximum length of matched sequences, between MAX_MATCH_LEN_MIN and MAX_MATCH_LEN_MAX.commonbyte (
int) – Value used to fill the initial ring buffer, must be 0-255.
- Returns:
Compressed data as bytes.
- Raises:
LZSSWException – If any parameters are out of their valid ranges.