[Python-ideas] bitwise operations on bytes

Mark Dickinson dickinsm at gmail.com
Mon Aug 10 10:05:30 CEST 2009


On Sat, Aug 8, 2009 at 10:31 PM, Guido van Rossum<guido at python.org> wrote:
> [...] I'd be okay with a standard API to transform a
> byte array into an integer and vice versa -- there you can be explicit
> about byte order and what to do about negative numbers. [...]

That would also be a welcome addition.  It's been requested on
bugs.python.org at least a couple of times[1][2], and the C code
to do the conversions already exists (_PyLong_{As,From}_ByteArray
in longobject.c), so it wouldn't be too much work to implement.

The main problem would be deciding exactly what the API should be
and where to put it.

Mark

[1] http://bugs.python.org/issue1023290
[2] http://bugs.python.org/issue923643



More information about the Python-ideas mailing list