A byte-level compression library implementing RLE and LZ77 with explicit encoding formats, manual pipelines, and automatic algorithm selection.
Project description
simple-compression
simple-compression is a small Python library that implements classic byte-oriented compression algorithms with an explicit and composable API.
The library is designed to operate directly on bytearray data and provides both manual and automatic compression pipelines. All encoded outputs are self-describing and can be decoded without external metadata.
Current version: v0.1.0
Scope and goals
This project focuses on:
- Correct, deterministic implementations of classic compression algorithms
- Explicit encoding formats that are easy to inspect and reason about
- A simple API for chaining multiple compression stages
- Safe and strict decoding
This library does not attempt to compete with production compressors in performance. It is intended for correctness, clarity, and control.
Implemented algorithms
- Run-Length Encoding (RLE)
- LZ77
Each algorithm has a fully defined binary format and a strict decoder.
Installation
pip install simple-compression
Basic Usage
Both of these features are expected to improve in effectiveness with more testing and tuning as well as the future implementation of a Huffman Algorithm
The first usage uses the auto=True argument does a quick pass on the data to gather metrics to automatically select the algorithms and their sequence.
The second usage passes the algorithm name as arguments to manually select algorithms and determine their sequence.
from simple_compression.compression import SimpleCompression
compress = SimpleCompression()
data = bytearray(b"AAAAAABBBBBCCDSADDDDDSSSCVZCSSSSWEEEFWEWAFZCVAGQWTQL")
encoded = compress.encode(data, auto=True)
decoded = compress.decode(encoded)
encoded = compress.encode(data, sequence=["RLE", "LZ77"])
decoded = compress.decode(encoded)
The decoder reads header tokens embedded at the start of the bitstream to determine which algorithms were applied and in which order. This allows for a really robust decoder which when combined with the spec documentation for each algorithm can be helpful in implementing decoders in other languages.
Algorithm Formatting
Detailed binary formats for each algorithm are documented below. RLE Format LZ77 Format
Road Map
First is implementing a Huffman algorithm to really take advantage of the sequencing ability of this library. As features are added the automatic sequencing feature will be continuously tuned to ensure that rle is only enabled when it doesn't infalte the input. As algorithms are added sequencing logic and metrics will develop alongside.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simple_compression-0.1.0.tar.gz.
File metadata
- Download URL: simple_compression-0.1.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
898ed635069c6a49ae59bd14ebf1c920ca913cb6886e8cbba8c76bddf4d621c9
|
|
| MD5 |
1fe56432d4804773f11dfe7f1c63a3df
|
|
| BLAKE2b-256 |
5af160e5c237b34eaa8d2b9ab7eb4d658cd233466c074ba6aaa5e388c928d695
|
File details
Details for the file simple_compression-0.1.0-py3-none-any.whl.
File metadata
- Download URL: simple_compression-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a87a0a8e69ba3028fbe0096a7641c30a2f6a74f4094f6254ad0827799333d8d
|
|
| MD5 |
7609bbf8e43f53d79b9829c30c688e46
|
|
| BLAKE2b-256 |
3105bea63c70346706aa03a6bfb2aa21c31b10c9d585d259c05efe5ecdac8c14
|