Huffman compression and decompression (Pure Python implementation)
Project description
Usage
from pyhuff import compress
text=b'A'*100
print(text) # b'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
comp=compress(text)
print(comp) # b'\x041\x00A\x010\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Or use:
pyhuff compress in.txt out.bin
pyhuff decompress out.bin dec.txt
Disadvantages
- The code is very messy because of compatibility of Python 2 (And I don't know the six package).
- Decompression is very slow.
- Not very good, sometimes the compressed file is larger than the original one.
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
PythonHuff-1.0.2.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for PythonHuff-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3e65c98d1d15a658dc71a6987ed8d2d69015936d7f87efca5d4af770f02b8ee |
|
MD5 | 7080351063afcfdbf2e05861f787bcd9 |
|
BLAKE2b-256 | 096d7a7e2b8d526c2ea89279039ecbc6df9483871d52ba5a1cc370a5475dc859 |