pyliblzfse

raw JSON →
0.4.1 verified Fri May 01 auth: no python maintenance

pyliblzfse provides Python bindings for the LZFSE reference implementation, offering compression and decompression using Apple's LZFSE algorithm. Version 0.4.1 is the latest release. The library is in maintenance mode with sparse updates.

pip install pyliblzfse
error ImportError: No module named 'pyliblzfse'
cause Package not installed or installed in wrong environment.
fix
Install with 'pip install pyliblzfse' and ensure virtual environment is activated.
error TypeError: a bytes-like object is required, not 'str'
cause Passing a string to compress() instead of bytes.
fix
Convert string to bytes: compress(data.encode())
error ValueError: data is not valid LZFSE compressed data
cause Decompressing data that is not LZFSE compressed.
fix
Ensure the data was compressed with compress() from this library, or verify input.
gotcha compress() and decompress() expect bytes, not strings. Passing str will raise TypeError.
fix Always encode strings to bytes before calling compress, e.g., b'text' or 'text'.encode()
deprecated Library updates are infrequent; may not support newer Python versions. Last release 2018.
fix Consider alternatives like pyLZFSE or using ctypes bindings for newer Python.
gotcha Compression output may be larger than input for small data. LZFSE is optimized for larger blocks.
fix Do not assume compression ratio for small inputs; use with large data or benchmark.

Compress and decompress bytes using LZFSE. Both compress and decompress expect bytes input and return bytes.

from pyliblzfse import compress, decompress

original = b"Hello, world!" * 1000
compressed = compress(original)
decompressed = decompress(compressed)
assert original == decompressed
print("LZFSE compression works!")