[Python-ideas] bitwise operations on bytes

MRAB python at mrabarnett.plus.com
Sun Aug 9 23:32:14 CEST 2009


Guido van Rossum wrote:
> On Sat, Aug 8, 2009 at 10:29 PM, Facundo
> Batista<facundobatista at gmail.com> wrote:
>> On Sat, Aug 8, 2009 at 6:31 PM, Guido van Rossum<guido at python.org> wrote:
>>
>>> 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
>> Indeed.  But let me rephrase this.
>>
>> I don't know Python, I'm just starting with Py3k, and I see a bytes
>> object. I don't know what a "byte string" is  (and I even feel that
>> the term is strange), but I understand that b"b3\xdd" is an array of
>> three bytes, which, of course, is an array of 24 bits (unless I know
>> that bytes are not always octets, but I think it's the same for this
>> case).
>>
>> So, I think that providing bit semantics is a must for bytes objects.
>>
>> I don't care (or I don't know enough to know that this exist) about
>> big/little endian, I just assume that this "just works" (it's is the
>> same case with line ending bytes: I may not know that different OSs
>> finish lines with different marks).
> 
> Sounds like a non-sequitur if anything.
> 
>>From the perspective of "I don't know Python" you cannot expect to
> draw valid conclusions.
> 
I think that bitstrings would be better handled by a distinct bitstring
class.



More information about the Python-ideas mailing list