pylzss - LZSS Compression Library
pylzss is a Python library designed for decoding and encoding data compressed with the LZSS algorithm. It provides efficient handling of LZSS-compressed streams, often found in embedded systems or older file formats. The current version is 0.3.8, with recent releases focusing on bug fixes, build system improvements, and wider platform support.
Common errors
-
ModuleNotFoundError: No module named 'pylzss'
cause The pylzss library is not installed in your current Python environment.fixInstall the library using pip: `pip install pylzss` -
SystemError: PY_SSIZE_T_CLEAN should be defined for functions that use 's#' formats
cause You are using an older version of pylzss (prior to 0.3.1) with Python 3.10 or a newer Python version, which introduced breaking changes for C extensions.fixUpgrade pylzss to version 0.3.1 or higher: `pip install --upgrade pylzss` -
ERROR: Could not find a version that satisfies the requirement pylzss==0.3.5
cause Version 0.3.5 of pylzss was removed from PyPI due to severe issues, making it unavailable for installation.fixInstall a newer, stable version of pylzss, such as 0.3.6 or later: `pip install pylzss>=0.3.6`
Warnings
- breaking Version 0.3.5 was pulled from PyPI due to critical issues. Attempting to install or use it will lead to unexpected behavior or installation failures.
- breaking Version 0.3.3 was incorrectly versioned and never properly released to PyPI. It should be avoided as it may cause installation problems or contain critical bugs.
- gotcha Versions of `pylzss` older than 0.3.1 can raise a `SystemError` when used with Python 3.10 or newer due to API changes in Python's C extension handling.
Install
-
pip install pylzss
Imports
- LzssDecoder
from pylzss import LzssDecoder
- LzssEncoder
from pylzss import LzssEncoder
Quickstart
from pylzss import LzssEncoder, LzssDecoder
# Example data
original_data = b"A Python library for decoding/encoding LZSS-compressed data. " * 5
# Encode the data
encoder = LzssEncoder()
encoded_data = encoder.encode(original_data)
print(f"Original size: {len(original_data)} bytes")
print(f"Encoded size: {len(encoded_data)} bytes")
# Decode the data
decoder = LzssDecoder()
decoded_data = decoder.decode(encoded_data)
print(f"Decoded size: {len(decoding_data)} bytes")
assert original_data == decoded_data
print("Encoding and decoding successful!")