[Python-ideas] String and bytes bitwise operations
facundobatista at gmail.com
Fri May 18 12:49:58 EDT 2018
2018-05-18 13:32 GMT-03:00 Chris Barker via Python-ideas
<python-ideas at python.org>:
> or would it operate on the whole sequence as a single collection of bits?
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
> Would it be any different? Without thinking hard, it seems some operations,
> like AND and OR and XOR would be the same, but bit shifting would be
AND, XOR and OR are simple. Bit shifting will shift bits for the whole
> And then what do you do if the two bytes objects are not the same length?
Pad with 0s to the left. Exactly the same that happen in
>>> 1 ^ 1231312312
More information about the Python-ideas