[Python-ideas] bitwise operations on bytes

Georg Brandl g.brandl at gmx.net
Sun Aug 9 00:09:42 CEST 2009


Guido van Rossum schrieb:

> In the grander scheme of things, I worry that interpreting byte
> strings as integers and implementing bitwise operators on them is
> going to cause more confusion and isn't generally useful enough to
> warrant the extra code.

What about operations that don't require the bytes to be interpreted
as anything else?

The OP proposed

bytes_a | bytes_b

to mean

bytes(b_a | b_b for (b_a, b_b) in zip(bytes_a, bytes_b))

except that (probably) an equal length would have to be asserted.

Georg

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.




More information about the Python-ideas mailing list