"Byte" type?

John Nagle nagle at animats.com
Sat Feb 21 06:33:38 CET 2009


Steve Holden wrote:
> John Nagle wrote:
>> Benjamin Kaplan wrote:
>>> On Sun, Feb 15, 2009 at 11:57 AM, John Nagle <nagle at animats.com> wrote:
>>>
...Re "bytes" not behaving as documented in 2.6:

>>    That's indeed how Python 2.6 works.  But that's not how
>> PEP 3137 says it's supposed to work.
>>
>> Guido:
>>
>>  "I propose the following type names at the Python level:
>>
>>         * bytes is an immutable array of bytes (PyString)
>>         * bytearray is a mutable array of bytes (PyBytes)"
...
>> (Not true in Python 2.6 
>>
>> Is this a bug, a feature, a documentation error, or bad design?
>>
> It's a feature. In fact all that was done to accommodate easier
> migration to 3.x is easily shown in one statement:
> 
>>>> str is bytes
> True
> 
> So that's why bytes works the way it does in 2.6 ... hence my contested
> description of it as an "ugly hack". I am happy to withdraw "ugly", but
> I think "hack" could still be held to apply.

    Agreed.  But is this a 2.6 thing, making 2.6 incompatible with 3.0, or
what?  How will 3.x do it?  The PEP 3137 way, or the Python 2.6 way?

    The way it works in 2.6 makes it necessary to do "ord" conversions
where they shouldn't be required.

				John Nagle



More information about the Python-list mailing list