[Python-Dev] Base-96

Josiah Carlson josiah.carlson at gmail.com
Sat Aug 2 19:37:34 CEST 2008

On Sat, Aug 2, 2008 at 10:09 AM, "Martin v. Löwis" <martin at v.loewis.de> wrote:
> Josiah Carlson wrote:
>> The standard high-bit-density encoding past base-64 is base-85
>> (http://en.wikipedia.org/wiki/Ascii85), which encodes 4 binary bytes
>> as 5 ascii bytes, versus 3 binary bytes as 4 ascii bytes.  It works,
>> is an RFC somewhere,
> RFC 1924, published on April 1, 1996, to shorten the representation
> of IPv6 addresses, so that you can write
>  ssh '4)+k&C#VzJ4br>0wv%Yp'
> instead of having to write
>  ssh 1080:0:0:0:8:800:200C:417A
> Most notably, section 7 (implementation issues) points out
>   Many current processors do not find 128 bit integer arithmetic, as
>   required for this technique, a trivial operation.  This is not
>   considered a serious drawback in the representation, but a flaw of
>   the processor designs.
> For arbitrary-sized data, you'd have to give up 128-bit arithmetic,
> of course, and represent the input data to encode as a long integer.
> Regards,
> Martin
> P.S. Just in case it isn't clear: I would oppose any specific proposal
> to add this Ascii85 algorithm to the standard library. It would sound
> like we don't have any real problems to solve.

Original intent (encoding IPV6 addresses) != current usefulness (a
more efficient ascii encoding of binary data).  Generally, I'm of the
opinion that base64 (as an ascii encoding of binary data) is
sufficient for any needs I have, but there are cases where having a
more efficient representation would be useful. I would also not
suggest addition in the 2.6/3.0 timeframe, at best it would be
2.7/3.1, and only if someone submits a patch with testcases (note that
the wiki page provides C source for one-shot encoding and decoding
that doesn't require 128-bit arithmetic).

Sounds to me like a project for the OP.

 - Josiah

More information about the Python-Dev mailing list