"Byte" type?

"Martin v. Löwis" martin at v.loewis.de
Tue Feb 24 01:11:38 EST 2009


>> Depends on how you write your code. If you use the bytearray type
>> (which John didn't, despite his apparent believe that he did),
>> then no conversion additional conversion is needed.
> 
>     According to PEP 3137, there should be no distinction between
> the two for read purposes.  In 2.6, there is.  That's a bug.

No. Python 2.6 doesn't implement PEP 3137, and the PEP doesn't claim
that it would, nor do the 2.6 release notes. So that it deviates from
PEP 3137 is not a bug.

>    No, it's broken.  PEP 3137 says one thing, and the 2.6 implementation
> does something else.  So code written for 2.6 won't be ready for 3.0.
> This defeats the supposed point of 2.6.

That's not true: if I write

   if isinstance(x, bytes):
      one_thing()
   elif isinstance(x, unicode):
      another_thing()

then 2to3 will convert it perfectly. 2to3 couldn't have done the
conversion correctly had I written

   if isinstance(x, str):
      one_thing()
   elif isinstance(x, unicode):
      another_thing()

So the introduction of the bytes builtin *does* help the supposed
point of 2.6, even though it doesn't help implementing PEP 3137.

Regards,
Martin



More information about the Python-list mailing list