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 gu...@python.org wrote: On Sun, Aug 17, 2014 at 5:22 PM, Barry Warsaw ba...@python.org 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

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 ncogh...@gmail.com wrote: On 18 August 2014 10:45, Guido van Rossum gu...@python.org wrote: On Sun, Aug 17, 2014 at 5:22 PM, Barry Warsaw ba...@python.org wrote: On Aug 18, 2014, at 10:08 AM, Nick Coghlan wrote: There's actually another

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

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 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 pain is a byte scalar. numpy has a scalar type for every type it

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 ba...@python.org 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

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 tjre...@udel.edu 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 -

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

2014-08-17 Thread Ian Cordasco
On Aug 17, 2014 12:17 PM, Donald Stufft don...@stufft.io wrote: On Aug 17, 2014, at 1:07 PM, Raymond Hettinger raymond.hettin...@gmail.com wrote: On Aug 17, 2014, at 1:41 AM, Nick Coghlan ncogh...@gmail.com wrote: If I see bytearray(10) there is nothing there that suggests this creates an

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

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 Nick Coghlan
On 18 Aug 2014 08:04, Markus Unterwaditzer mar...@unterwaditzer.net 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

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 name, but

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 ba...@python.org 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 the

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 =

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 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, while bytes.bytes behaves like a tuple of bytes? I would explain it

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 iterator

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 ba...@python.org 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

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 ba...@python.org 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

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 ba...@python.org mailto:ba...@python.org wrote: On Aug 18, 2014,

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 ba...@python.org 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