python implementation of a new integer encoding algorithm.

Chris Angelico rosuav at gmail.com
Wed Feb 18 04:36:10 EST 2015


On Wed, Feb 18, 2015 at 7:55 PM,  <janhein.vanderburg at gmail.com> wrote:
>> Take the
>> easy option; you can always make things more complicated later.
> That makes sense alright.
> No offense, but I still believe that human readable text encoding complicates things right now and shouldn't be tried until "my way" has proven unpractical in its first application.
> Consider it to be a theoretical challenge: how do I find the general encoding of an arbitrary integer value that minimizes the number of bits needed and given that algorithm, find the python code that minimizes the processor load inflicted by the codec implementation.
>

I would actually look at it the other way: a human-readable encoding
is the easy way (you can simply print() your numbers and int() them on
the way back in), and until you can prove that it's impractical, don't
write a single line of code towards this algorithm. But let's get some
figures, though: How many payload bits per byte can you achieve?
What's your average going to be? You have two baselines to beat: 4
bits per byte (hexadecimal), and 7 bits per byte (MIDI varlen, or
whatever you want to call it; I first met it with MIDI, but it's been
used in so many places that other people have other names for it).

ChrisA



More information about the Python-list mailing list