Accelerator for Ascii85/Base85

The base64 module supports not only standard encodings Base 16, Base 32 and Base 64, specified in RFC 4648, but also non-standart encodings Ascii85, Base85 and Z85. The latter are implemented in Python. While the Python code was hightly optimazed without the loss of maintenability, it is still 100 times slower and uses 50 times more memory than encodings implemented in C. There is a PR for implementing these functions in C.

The question is – should we kept the Python code? binascii is a non-optional dependency of base64, any CPython build should have binascii for working base64. Alternative Python implementation, if they use base64.py, should implement binascii. Should we provide a Python fallback for the case if they don’t implement Ascii85/Base85 in binascii (this code is more complex than for Base 64), or they should just copy the Python code from the older version? Supporting both implementations has a non-trivial cost, so we have to weigh whether it’s worth doing.

If binascii is a non-optional dependency for the more common base64 encoding and no python fallback was needed then, it doesn’t seem worth the hassle trying to provide a pure python fallback for less common encodings.

1 Like

Agreed, I’d drop the old python code.