Python implementation of carry-less range coder
Project description
Both static and dynamic encoding can be used.
Install
$ pip install CarryLessRangeCoder
Examples
from collections import Counter
import carryless_rangecoder as rc
from io import BytesIO
data = list(map(ord, 'qawsedrftgyhujikolp;'))
count = [1] * 256
for i, c in Counter(data).items():
count[i] += c
count_cum = [0] * 256
for i in range(1, 256):
count_cum[i] = count[i] + count_cum[i - 1]
out = BytesIO()
# Encode
with rc.Encoder(out) as enc: # or enc.finish()
for index in data:
enc.encode(count, count_cum, index)
# Decode
decoded = []
with rc.Decode(out) as dec: # or dec.start()
for _ in range(len(data)):
decoded.append(dec.decode(count, count_cum))
assert decoded == data
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
File details
Details for the file CarryLessRangeCoder-1.0.2.tar.gz.
File metadata
- Download URL: CarryLessRangeCoder-1.0.2.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f56d69ef2b745d979d223601a2810ddfd0dd3da0fafdd7b194aa2606b7ac1314
|
|
| MD5 |
aa0a45435d6aaca1fbe7279ec0b54aee
|
|
| BLAKE2b-256 |
32f6641bf20c6b5d29bb866e8ed222a9800ea60be120dea99483f12945853b9f
|