[Python-ideas] String and bytes bitwise operations
kenlhilton at gmail.com
Fri May 18 23:58:28 EDT 2018
On Fri, 18 May 2018 13:49:58 -0300, Facundo Batista wrote:
> Once you think as the whole sequence of bytes as a sequence of bits (eight
times longer, of course), all questions are easly answered, see below...
I had never considered this before, but it seems very interesting.
Essentially that would make bytes1 ^ bytes2 be equivalent to
(int.from_bytes(bytes1, sys.byteorder) ^ int.from_bytes(bytes2,
sys.byteorder)).to_bytes(max(len(bytes1), len(bytes2)), sys.byteorder)
bytes(a ^ b for a, b in zip(bytes1, bytes2))
I like that idea more than my original elementwise idea.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas