pylzss - LZSS Compression Library

0.3.8 · active · verified Thu Apr 16

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

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `pylzss` to compress and decompress a byte string. It initializes an `LzssEncoder` to compress the `original_data` and then uses an `LzssDecoder` to reconstruct it, verifying that the decoded data matches the original.

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!")

view raw JSON →