[Python-ideas] Bitwise operations on bytes class
Terry Reedy
tjreedy at udel.edu
Mon Jun 16 21:20:33 CEST 2014
On 6/16/2014 2:03 PM, Nathaniel McCallum wrote:
> I find myself, fairly often, needing to perform bitwise operations
> (rshift, lshift, and, or, xor) on arrays of bytes in python (both bytes
> and bytearray).
If you are often doing and/or/xor on large arrays, as one might do for
bitmap images, you should probably be using numpy or a derivative thereof.
What use do you have for shifting bits across byte boundaries, where the
bytes are really bytes? Why would you not turn multiple bytes
considered together into an int?
> I can't think of any other reasonable use for these operators.
I don't understand this. They are routinely used on ints for various
purposes.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list