I see that the binascii module has several {a2b,b2a}_xyz functions for several
flavors of ascii <-> binary conversions. But it misses a general base function
set parameterized with a radix.
It would be nice to add a generic set of {a2b|b2a}(s, radix=r, case={'u','l'}),
where radix is a power of 2 < 36 (2, 4, 8, 16 or 32) and case is only
significant for b2a, to cover all trivial ascii <-> binary conversions using an
efficient native implementation. Most {a2b,b2a}_xyz can just call the generic
{a2b|b2a} with the appropriate radix.
'radix' could also be called 'base' for consistency with the int() functions.
I was actually surprised that it wasn't the case already...
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/6TIJ2K472QT3FBEYZBTB5IISQ426SAUO/
Code of Conduct: http://python.org/psf/codeofconduct/