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

2014-08-18 Thread Barry Warsaw
On Aug 17, 2014, at 09:39 PM, Antoine Pitrou wrote: >> need for a special case for a single byte. We already have a perfectly >> good spelling: >> NUL = bytes([0]) > >That is actually a very cumbersome spelling. Why should I first create a >one-element list in order to create a one-byte bytes

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

2014-08-17 Thread Devin Jeanpierre
On Sun, Aug 17, 2014 at 7:14 PM, Alex Gaynor wrote: > I've hit basically every problem everyone here has stated, and in no uncertain > terms am I completely opposed to deprecating anything. The Python 2 to 3 > migration is already hard enough, and already proceeding far too slowly for > many of ou

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

2014-08-17 Thread Alex Gaynor
Donald Stufft stufft.io> writes: > > > > For the record I’ve had all of the problems that Nick states and I’m > +1 on this change. > > > --- > Donald Stufft > PGP: 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA > I've hit basically every problem everyone here has stated, and in no uncer

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

2014-08-17 Thread Ian Cordasco
On Sun, Aug 17, 2014 at 8:52 PM, Ethan Furman wrote: > On 08/17/2014 04:08 PM, Nick Coghlan wrote: >> >> >> I'm fine with postponing the deprecation elements indefinitely (or just >> deprecating bytes(int) and leaving >> bytearray(int) alone). > > > +1 on both pieces. Perhaps postpone the depreca

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

2014-08-17 Thread Ethan Furman
On 08/17/2014 04:08 PM, Nick Coghlan wrote: I'm fine with postponing the deprecation elements indefinitely (or just deprecating bytes(int) and leaving bytearray(int) alone). +1 on both pieces. -- ~Ethan~ ___ Python-Dev mailing list Python-Dev@pytho

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

2014-08-17 Thread Ethan Furman
On 08/17/2014 02:19 PM, Raymond Hettinger wrote: On Aug 17, 2014, at 11:33 AM, Ethan Furman wrote: I've had many of the problems Nick states and I'm also +1. There are two code snippets below which were taken from the standard library. [...] My issues are with 'bytes', not 'bytearray'. 'b

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

2014-08-17 Thread Antoine Pitrou
Le 17/08/2014 19:41, Raymond Hettinger a écrit : The APIs have been around since 2.6 and AFAICT there have been zero demonstrated need for a special case for a single byte. We already have a perfectly good spelling: NUL = bytes([0]) That is actually a very cumbersome spelling. Why should

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

2014-08-17 Thread Nick Coghlan
On 18 Aug 2014 09:41, "Raymond Hettinger" wrote: > > > I encourage restraint against adding an unneeded class method that has no parallel > elsewhere. Right now, the learning curve is mitigated because bytes is very str-like > and because bytearray is list-like (i.e. the method names have been us

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

2014-08-17 Thread Raymond Hettinger
On Aug 17, 2014, at 4:08 PM, Nick Coghlan wrote: > Purely deprecating the bytes case and leaving bytearray alone would likely > address my concerns. That is good progress. Thanks :-) Would a warning for the bytes case suffice, do you need an actual deprecation? > bytes.byte() thus becomes t

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

2014-08-17 Thread Antoine Pitrou
Le 16/08/2014 01:17, Nick Coghlan a écrit : * Deprecate passing single integer values to ``bytes`` and ``bytearray`` I'm neutral. Ideally we wouldn't have done that mistake at the beginning. * Add ``bytes.zeros`` and ``bytearray.zeros`` alternative constructors * Add ``bytes.byte`` and ``by

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

2014-08-17 Thread Nick Coghlan
On 18 Aug 2014 03:07, "Raymond Hettinger" wrote: > > > On Aug 17, 2014, at 1:41 AM, Nick Coghlan wrote: > >> If I see "bytearray(10)" there is nothing there that suggests "this >> creates an array of length 10 and initialises it to zero" to me. I'd >> be more inclined to guess it would be equival

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

2014-08-17 Thread Antoine Pitrou
Le 17/08/2014 13:07, Raymond Hettinger a écrit : FWIW, I've been teaching Python full time for three years. I cover the use of bytearray(n) in my classes and not a single person out of 3000+ engineers have had a problem with it. This is less about bytearray() than bytes(), IMO. bytearray() i

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

2014-08-17 Thread Donald Stufft
> On Aug 17, 2014, at 5:19 PM, Raymond Hettinger > wrote: > > > On Aug 17, 2014, at 11:33 AM, Ethan Furman > wrote: > >> I've had many of the problems Nick states and I'm also +1. > > There are two code snippets below which were taken from the standard library. >

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

2014-08-17 Thread Raymond Hettinger
On Aug 17, 2014, at 11:33 AM, Ethan Furman wrote: > I've had many of the problems Nick states and I'm also +1. There are two code snippets below which were taken from the standard library. Are you saying that: 1) you don't understand the code (as the pep suggests) 2) you are willing to break th

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

2014-08-17 Thread Ethan Furman
On 08/17/2014 10:16 AM, Donald Stufft wrote: For the record I’ve had all of the problems that Nick states and I’m +1 on this change. I've had many of the problems Nick states and I'm also +1. -- ~Ethan~ ___ Python-Dev mailing list Python-Dev@python.

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

2014-08-17 Thread Donald Stufft
> On Aug 17, 2014, at 1:07 PM, Raymond Hettinger > wrote: > > > On Aug 17, 2014, at 1:41 AM, Nick Coghlan > wrote: > >> If I see "bytearray(10)" there is nothing there that suggests "this >> creates an array of length 10 and initialises it to zero" to me. I'd >> be

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

2014-08-17 Thread Raymond Hettinger
On Aug 17, 2014, at 1:41 AM, Nick Coghlan wrote: > If I see "bytearray(10)" there is nothing there that suggests "this > creates an array of length 10 and initialises it to zero" to me. I'd > be more inclined to guess it would be equivalent to "bytearray([10])". > > "bytearray.zeros(10)", on th

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

2014-08-17 Thread Nick Coghlan
On 17 August 2014 18:13, Raymond Hettinger wrote: > > On Aug 14, 2014, at 10:50 PM, Nick Coghlan wrote: > > Key points in the proposal: > > * deprecate passing integers to bytes() and bytearray() > > > I'm opposed to removing this part of the API. It has proven useful > and the alternative isn't

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

2014-08-17 Thread Raymond Hettinger
On Aug 14, 2014, at 10:50 PM, Nick Coghlan wrote: > Key points in the proposal: > > * deprecate passing integers to bytes() and bytearray() I'm opposed to removing this part of the API. It has proven useful and the alternative isn't very nice. Declaring the size of fixed length arrays is no

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

2014-08-15 Thread Nick Coghlan
On 16 August 2014 03:48, Guido van Rossum wrote: > This feels chatty. I'd like the PEP to call out the specific proposals and > put the more verbose motivation later. I realised that some of that history was actually completely irrelevant now, so I culled a fair bit of it entirely. > It took me

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

2014-08-15 Thread Victor Stinner
2014-08-15 7:50 GMT+02:00 Nick Coghlan : > As far as I am aware, that last item poses the only open question, > with the alternative being to add an "iterbytes" builtin (...) Do you have examples of use cases for a builtin function? I only found 5 usages of bytes((byte,)) constructor in the standa

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

2014-08-15 Thread Victor Stinner
2014-08-15 21:54 GMT+02:00 Serhiy Storchaka : > 15.08.14 08:50, Nick Coghlan написав(ла): >> * add bytes.zeros() and bytearray.zeros() as a replacement > > b'\0' * n and bytearray(b'\0') * n look good replacements to me. No need to > learn new method. And it works right now. FYI there is a pending

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

2014-08-15 Thread Serhiy Storchaka
15.08.14 08:50, Nick Coghlan написав(ла): * add bytes.zeros() and bytearray.zeros() as a replacement b'\0' * n and bytearray(b'\0') * n look good replacements to me. No need to learn new method. And it works right now. * add bytes.iterbytes(), bytearray.iterbytes() and memoryview.iterbytes(

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

2014-08-15 Thread Guido van Rossum
This feels chatty. I'd like the PEP to call out the specific proposals and put the more verbose motivation later. It took me a long time to realize that you don't want to deprecate bytes([1, 2, 3]), but only bytes(3). Also your mention of bytes.byte() as the counterpart to ord() confused me -- I th