rahuketu is a small zero-free encoding package. It combines a signed bijective number path (Rahu) with an arithmetic-coding path (Ketu), and records both as a log-space trace. Pure Python, no dependencies.
pip install rahuketu
from rahuketu import Alphabet, roundtrip, trace
ab = Alphabet.lowercase()
r = roundtrip("hello", ab)
assert r["agrees"] # encode -> decode is lossless
steps = trace("hello", ab)
last = steps[-1]
print(last.tau, last.upsilon, last.redundancy)Alphabet- no-zero symbol/digit mapping (digits in[1, b]).Rahu- signed bijective numeration (RahuState,rahu_encode,rahu_decode).Ketu- arithmetic coding as(midpoint, scale)(KetuState,ketu_encode,ketu_decode).trace- records(tau, upsilon, a)over the input.roundtrip- checks lossless encode/decode.
Built by Ramakrishnan (ORCID 0009-0006-0905-7275). Signed and bijective numeration and arithmetic coding are classical methods. The zero-free Rahu-Ketu framing and this implementation are original. AI tools helped with tests, automation, and QA. The idea and direction are the author's.
Apache-2.0. See LICENSE and NOTICE.