[Python-Dev] Fwd: PEP 467: Minor API improvements for bytes & bytearray

Chris McDonough chrism at plope.com
Mon Aug 18 04:51:26 CEST 2014


On 08/17/2014 09:40 PM, Antoine Pitrou wrote:
> Le 17/08/2014 20:08, Nick Coghlan a écrit :
>>
>> On 18 Aug 2014 09:57, "Barry Warsaw" <barry at python.org
>> <mailto:barry at python.org>> wrote:
>>  >
>>  > On Aug 18, 2014, at 09:12 AM, Nick Coghlan wrote:
>>  >
>>  > >I'm talking more generally - do you *really* want to be explaining
>> that
>>  > >"bytes" behaves like a tuple of integers, while "bytes.bytes"
>> behaves like
>>  > >a tuple of bytes?
>>  >
>>  > I would explain it differently though, using concrete examples.
>>  >
>>  >     data = bytes(...)
>>  >     for i in data: # iterate over data as integers
>>  >     for i in data.bytes: # iterate over data as bytes
>>  >
>>  > But whatever.  I just wish there was something better than iterbytes.
>>
>> There's actually another aspect to your idea, independent of the naming:
>> exposing a view rather than just an iterator.
>
> So that view would actually be the bytes object done right? Funny :-)
> Will it have lazy slicing?

bytes.sorry()? ;-)

- C




More information about the Python-Dev mailing list