Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-07-18 Thread Ethan Furman
On 06/07/2016 02:34 PM, Koos Zevenhoven wrote: Why not bytes.viewbytes (or whatever name) so that one could also subscript it? And if it were a property, one could perhaps conveniently get the n'th byte: b'abcde'.viewbytes[n] # compared to b'abcde'[n:n+1] AFAICT, 'viewbytes' doesn't add

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-07-16 Thread Ethan Furman
On 06/07/2016 10:42 PM, Serhiy Storchaka wrote: On 07.06.16 23:28, Ethan Furman wrote: * Add ``bytes.iterbytes``, ``bytearray.iterbytes`` and ``memoryview.iterbytes`` alternative iterators "Byte" is an alias to "octet" (8-bit integer) in modern terminology. Maybe so, but not, to my

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-10 Thread Nick Coghlan
On 9 June 2016 at 19:21, Barry Warsaw wrote: > On Jun 07, 2016, at 01:28 PM, Ethan Furman wrote: > >>Deprecation of current "zero-initialised sequence" behaviour >> >> >>Currently, the ``bytes`` and ``bytearray``

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-08 Thread Franklin? Lee
On Jun 8, 2016 8:13 AM, "Paul Sokolovsky" wrote: > > Hello, > > On Wed, 8 Jun 2016 14:45:22 +0300 > Serhiy Storchaka wrote: > > [] > > > > $ ./run-bench-tests bench/bytealloc* > > > bench/bytealloc: > > > 3.333s (+00.00%) bench/bytealloc-1-bytes_n.py

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-08 Thread Steven D'Aprano
On Wed, Jun 08, 2016 at 10:04:08AM +0200, Victor Stinner wrote: > It's common that users complain that Python core developers like > breaking the compatibility at each release. No more common as users complaining that Python features are badly designed and crufty and should be fixed. Whatever

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-08 Thread Barry Warsaw
On Jun 08, 2016, at 02:01 AM, Martin Panter wrote: >Bytes.byte() is a great idea. But what’s the point or use case of >bytearray.byte(), a mutable array of one pre-defined byte? I like Bytes.byte() too. I would guess you'd want the same method on bytearray for duck typing APIs. -Barry

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-08 Thread Paul Sokolovsky
Hello, On Wed, 8 Jun 2016 14:45:22 +0300 Serhiy Storchaka wrote: [] > > $ ./run-bench-tests bench/bytealloc* > > bench/bytealloc: > > 3.333s (+00.00%) bench/bytealloc-1-bytes_n.py > > 11.244s (+237.35%) bench/bytealloc-2-repeat.py > > If the performance of

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-08 Thread Serhiy Storchaka
On 08.06.16 14:26, Paul Sokolovsky wrote: On Wed, 8 Jun 2016 14:05:19 +0300 Serhiy Storchaka wrote: On 08.06.16 13:37, Paul Sokolovsky wrote: The obvious way to create the bytes object of length n is b'\0' * n. That's very inefficient: it requires allocating useless

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-08 Thread Paul Sokolovsky
Hello, On Wed, 8 Jun 2016 14:05:19 +0300 Serhiy Storchaka wrote: > On 08.06.16 13:37, Paul Sokolovsky wrote: > >> The obvious way to create the bytes object of length n is b'\0' * > >> n. > > > > That's very inefficient: it requires allocating useless b'\0', then > > a

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-08 Thread Serhiy Storchaka
On 08.06.16 13:37, Paul Sokolovsky wrote: The obvious way to create the bytes object of length n is b'\0' * n. That's very inefficient: it requires allocating useless b'\0', then a generic function to repeat arbitrary memory block N times. If there's a talk of Python to not be laughed at for

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-08 Thread Paul Sokolovsky
Hello, On Wed, 8 Jun 2016 11:53:06 +0300 Serhiy Storchaka wrote: > On 08.06.16 11:04, Victor Stinner wrote: > >> Currently, the ``bytes`` and ``bytearray`` constructors accept an > >> integer argument and interpret it as meaning to create a > >> zero-initialised sequence of

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-08 Thread Serhiy Storchaka
On 08.06.16 02:03, Nick Coghlan wrote: That said, it occurs to me that there's a reasonably strong composability argument in favour of a view-based approach: a view will work with operator.itemgetter() and other sequence consuming APIs, while special methods won't. The "like-memoryview-but-not"

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-08 Thread Serhiy Storchaka
On 08.06.16 11:04, Victor Stinner wrote: Currently, the ``bytes`` and ``bytearray`` constructors accept an integer argument and interpret it as meaning to create a zero-initialised sequence of the given size:: (...) This PEP proposes to deprecate that behaviour in Python 3.6, and remove it

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-08 Thread Victor Stinner
Hi, > Currently, the ``bytes`` and ``bytearray`` constructors accept an integer > argument and interpret it as meaning to create a zero-initialised sequence > of the given size:: > (...) > This PEP proposes to deprecate that behaviour in Python 3.6, and remove it > entirely in Python 3.7. I'm

[Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-08 Thread Stephen J. Turnbull
Ethan Furman writes: > * Deprecate passing single integer values to ``bytes`` and > ``bytearray`` Why? This is a slightly awkward idiom compared to .zeros (EITBI etc), but your 32-bit clock will roll over before we can actually remove it. There are a lot of languages that do this kind of

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-07 Thread Serhiy Storchaka
On 07.06.16 23:28, Ethan Furman wrote: Minor changes: updated version numbers, add punctuation. The current text seems to take into account Guido's last comments. Thoughts before asking for acceptance? PEP: 467 Title: Minor API improvements for binary sequences Version: $Revision$

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-07 Thread Martin Panter
On 7 June 2016 at 21:56, Nick Coghlan wrote: > On 7 June 2016 at 14:33, Paul Sokolovsky wrote: >> Ethan Furman wrote: >>> Deprecation of current "zero-initialised sequence" behaviour >>>

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-07 Thread Steven D'Aprano
On Wed, Jun 08, 2016 at 02:17:12AM +0300, Paul Sokolovsky wrote: > Hello, > > On Tue, 07 Jun 2016 15:46:00 -0700 > Ethan Furman wrote: > > > On 06/07/2016 02:33 PM, Paul Sokolovsky wrote: > > > > >> This PEP proposes to deprecate that behaviour in Python 3.6, and > > >>

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-07 Thread Paul Sokolovsky
Hello, On Tue, 07 Jun 2016 15:46:00 -0700 Ethan Furman wrote: > On 06/07/2016 02:33 PM, Paul Sokolovsky wrote: > > >> This PEP proposes to deprecate that behaviour in Python 3.6, and > >> remove it entirely in Python 3.7. > > > > Why the desire to break applications of

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-07 Thread Nick Coghlan
On 7 June 2016 at 15:22, Koos Zevenhoven wrote: > On Wed, Jun 8, 2016 at 12:57 AM, Barry Warsaw wrote: >> On Jun 07, 2016, at 09:40 PM, Brett Cannon wrote: >> >>>On Tue, 7 Jun 2016 at 14:38 Paul Sokolovsky wrote: What's wrong with

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-07 Thread Ethan Furman
On 06/07/2016 02:33 PM, Paul Sokolovsky wrote: This PEP proposes to deprecate that behaviour in Python 3.6, and remove it entirely in Python 3.7. Why the desire to break applications of thousands and thousands of people? Besides, bytes(3) behavior is very logical. Everyone who knows what

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-07 Thread Koos Zevenhoven
On Wed, Jun 8, 2016 at 12:57 AM, Barry Warsaw wrote: > On Jun 07, 2016, at 09:40 PM, Brett Cannon wrote: > >>On Tue, 7 Jun 2016 at 14:38 Paul Sokolovsky wrote: >>> What's wrong with b[i:i+1] ? >>It always succeeds while indexing can trigger an IndexError. > >

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-07 Thread Barry Warsaw
On Jun 07, 2016, at 09:40 PM, Brett Cannon wrote: >On Tue, 7 Jun 2016 at 14:38 Paul Sokolovsky wrote: >> What's wrong with b[i:i+1] ? >It always succeeds while indexing can trigger an IndexError. Right. You want a method with the semantics of __getitem__() but that returns

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-07 Thread tritium-list
t;ba...@python.org> > Cc: python-dev@python.org > Subject: RE: [Python-Dev] PEP 467: Minor API improvements to bytes, > bytearray, and memoryview > > > > > -Original Message- > > From: Python-Dev [mailto:python-dev-bounces+tritium- > > list=sdamon@

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-07 Thread Nick Coghlan
On 7 June 2016 at 14:33, Paul Sokolovsky wrote: > Hello, > > On Tue, 07 Jun 2016 13:28:13 -0700 > Ethan Furman wrote: > >> Minor changes: updated version numbers, add punctuation. >> >> The current text seems to take into account Guido's last comments. >>

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-07 Thread tritium-list
> -Original Message- > From: Python-Dev [mailto:python-dev-bounces+tritium- > list=sdamon@python.org] On Behalf Of Nick Coghlan > Sent: Tuesday, June 7, 2016 5:40 PM > To: Barry Warsaw <ba...@python.org> > Cc: python-dev@python.org > Subject: Re: [Pyt

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-07 Thread Brett Cannon
On Tue, 7 Jun 2016 at 14:38 Paul Sokolovsky wrote: > Hello, > > On Tue, 7 Jun 2016 17:31:19 -0400 > Barry Warsaw wrote: > > > On Jun 07, 2016, at 01:28 PM, Ethan Furman wrote: > > > > >* Add ``bytes.iterbytes``, ``bytearray.iterbytes`` and > > >

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-07 Thread Nick Coghlan
On 7 June 2016 at 14:31, Barry Warsaw wrote: > On Jun 07, 2016, at 01:28 PM, Ethan Furman wrote: > >>* Add ``bytes.iterbytes``, ``bytearray.iterbytes`` and >> ``memoryview.iterbytes`` alternative iterators > > +1 but I want to go just a little farther. > > We can't change

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-07 Thread Paul Sokolovsky
Hello, On Tue, 7 Jun 2016 17:31:19 -0400 Barry Warsaw wrote: > On Jun 07, 2016, at 01:28 PM, Ethan Furman wrote: > > >* Add ``bytes.iterbytes``, ``bytearray.iterbytes`` and > > ``memoryview.iterbytes`` alternative iterators > > +1 but I want to go just a little farther. >

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-07 Thread Koos Zevenhoven
On Tue, Jun 7, 2016 at 11:28 PM, Ethan Furman wrote: > > Minor changes: updated version numbers, add punctuation. > > The current text seems to take into account Guido's last comments. > > Thoughts before asking for acceptance? > > PEP: 467 > Title: Minor API improvements for

Re: [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-07 Thread Barry Warsaw
On Jun 07, 2016, at 01:28 PM, Ethan Furman wrote: >* Add ``bytes.iterbytes``, ``bytearray.iterbytes`` and > ``memoryview.iterbytes`` alternative iterators +1 but I want to go just a little farther. We can't change bytes.__getitem__ but we can add another method that returns single byte

[Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

2016-06-07 Thread Ethan Furman
Minor changes: updated version numbers, add punctuation. The current text seems to take into account Guido's last comments. Thoughts before asking for acceptance? PEP: 467 Title: Minor API improvements for binary sequences Version: $Revision$ Last-Modified: $Date$ Author: Nick Coghlan