Skip to main content

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

  1. The code is very messy because of compatibility of Python 2 (And I don't know the six package).
  2. Decompression is very slow.
  3. Not very good, sometimes the compressed file is larger than the original one.

Project details


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.4.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

PythonHuff-1.0.4-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page