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

2014-08-19 Thread Guido van Rossum
On Tue, Aug 19, 2014 at 5:25 AM, Nick Coghlan wrote: > On 18 August 2014 10:45, Guido van Rossum wrote: > > On Sun, Aug 17, 2014 at 5:22 PM, Barry Warsaw wrote: > >> > >> On Aug 18, 2014, at 10:08 AM, Nick Coghlan wrote: > >> > >> >There's actually another aspect to your idea, independent of th

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

2014-08-19 Thread Nick Coghlan
On 18 August 2014 10:45, Guido van Rossum wrote: > On Sun, Aug 17, 2014 at 5:22 PM, Barry Warsaw wrote: >> >> On Aug 18, 2014, at 10:08 AM, Nick Coghlan wrote: >> >> >There's actually another aspect to your idea, independent of the naming: >> >exposing a view rather than just an iterator. I'm goi

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

2014-08-18 Thread Chris Barker
On Mon, Aug 18, 2014 at 1:06 PM, Terry Reedy wrote: > The byte scalar is an int in range(256). Bytes is an array of such. > then why the complaint about iterating over bytes producing ints? Ye,s a byte owuld be pretty much teh same as an int, but it would have restrictions - useful ones. numpy

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

2014-08-18 Thread Terry Reedy
On 8/18/2014 12:04 PM, Chris Barker wrote: On Sun, Aug 17, 2014 at 2:41 PM, Barry Warsaw mailto:ba...@python.org>> wrote: I think the biggest API "problem" is that default iteration returns integers instead of bytes. That's a real pain. what is really needed for this NOT to be a p

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

2014-08-18 Thread Chris Barker
On Sun, Aug 17, 2014 at 2:41 PM, Barry Warsaw wrote: > I think the biggest API "problem" is that default iteration returns > integers > instead of bytes. That's a real pain. > what is really needed for this NOT to be a pain is a byte scalar. numpy has a scalar type for every type it supports -

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

2014-08-18 Thread Barry Warsaw
On Aug 17, 2014, at 09:48 PM, Donald Stufft wrote: >from __future__ import bytesdoneright? :D Synonymous to: bytes = bytesdoneright or maybe from bytesdoneright import bytes :) -Barry ___ Python-Dev mailing list Python-Dev@python.org https://mail.p

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

2014-08-17 Thread Chris McDonough
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" mailto:ba...@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

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

2014-08-17 Thread Donald Stufft
from __future__ import bytesdoneright? :D -- Donald Stufft don...@stufft.io On Sun, Aug 17, 2014, at 09:40 PM, Antoine Pitrou wrote: > Le 17/08/2014 20:08, Nick Coghlan a écrit : > > > > On 18 Aug 2014 09:57, "Barry Warsaw" > > wrote: > > > > > > On Aug 18, 2014,

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

2014-08-17 Thread Antoine Pitrou
Le 17/08/2014 20:08, Nick Coghlan a écrit : On 18 Aug 2014 09:57, "Barry Warsaw" mailto:ba...@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, w

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

2014-08-17 Thread Guido van Rossum
On Sun, Aug 17, 2014 at 5:22 PM, Barry Warsaw wrote: > On Aug 18, 2014, at 10:08 AM, Nick Coghlan wrote: > > >There's actually another aspect to your idea, independent of the naming: > >exposing a view rather than just an iterator. I'm going to have to look at > >the implications for memoryview,

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

2014-08-17 Thread Barry Warsaw
On Aug 18, 2014, at 10:08 AM, Nick Coghlan wrote: >There's actually another aspect to your idea, independent of the naming: >exposing a view rather than just an iterator. I'm going to have to look at >the implications for memoryview, but it may be a good way to go (and would >align with the iterat

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

2014-08-17 Thread Nick Coghlan
On 18 Aug 2014 09:57, "Barry Warsaw" 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 d

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

2014-08-17 Thread Barry Warsaw
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 = byt

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

2014-08-17 Thread Nick Coghlan
On 18 Aug 2014 08:55, "Barry Warsaw" wrote: > > On Aug 18, 2014, at 08:48 AM, Nick Coghlan wrote: > > >Calling it bytes is too confusing: > > > >for x in bytes(data): > > ... > > > >for x in bytes(data).bytes() > > > >When referring to bytes, which bytes do you mean, the builtin or t

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

2014-08-17 Thread Barry Warsaw
On Aug 18, 2014, at 08:48 AM, Nick Coghlan wrote: >Calling it bytes is too confusing: > >for x in bytes(data): > ... > >for x in bytes(data).bytes() > >When referring to bytes, which bytes do you mean, the builtin or the method? > >iterbytes() isn't especially attractive as a method

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

2014-08-17 Thread Nick Coghlan
On 18 Aug 2014 08:04, "Markus Unterwaditzer" wrote: > > On Sun, Aug 17, 2014 at 05:41:10PM -0400, Barry Warsaw wrote: > > I think the biggest API "problem" is that default iteration returns integers > > instead of bytes. That's a real pain. > > I agree, this behavior required some helper function

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

2014-08-17 Thread Markus Unterwaditzer
On Sun, Aug 17, 2014 at 05:41:10PM -0400, Barry Warsaw wrote: > I think the biggest API "problem" is that default iteration returns integers > instead of bytes. That's a real pain. I agree, this behavior required some helper functions while porting Werkzeug to Python 3 AFAIK. > > I'm not sure .

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

2014-08-17 Thread Barry Warsaw
I think the biggest API "problem" is that default iteration returns integers instead of bytes. That's a real pain. I'm not sure .iterbytes() is the best name for spelling iteration over bytes instead of integers though. Given that we can't change __iter__(), I personally would perhaps prefer a s