Re: [Python-Dev] bytes & bytearray

2015-01-20 Thread Trent Nelson
On Tue, Jan 20, 2015 at 11:48:10AM +0200, Paul Sokolovsky wrote: > Hello, > > On Tue, 20 Jan 2015 18:15:02 +1300 > Greg Ewing wrote: > > > Guido van Rossum wrote: > > > On Mon, Jan 19, 2015 at 11:43 AM, Paul Sokolovsky > > > mailto:pmis...@gmail.com>> wrote: > > > > > > b.lower_inplace() >

Re: [Python-Dev] bytes & bytearray

2015-01-20 Thread Guido van Rossum
On Tue, Jan 20, 2015 at 1:48 AM, Paul Sokolovsky wrote: > The point of inplace operations (memoryview's, other stuff already in > Python) is to avoid unneeded memory allocation and copying. For 1Tb > bytearray with 1Tb of RAM, it will be very hard to do. (Ditto for 100K > bytearray with 150K RAM.

Re: [Python-Dev] bytes & bytearray

2015-01-20 Thread Paul Sokolovsky
Hello, On Tue, 20 Jan 2015 18:15:02 +1300 Greg Ewing wrote: > Guido van Rossum wrote: > > On Mon, Jan 19, 2015 at 11:43 AM, Paul Sokolovsky > > mailto:pmis...@gmail.com>> wrote: > > > > b.lower_inplace() > > b.lower_i() > > > > Please don't go there. The use cases are too rare. > > An

Re: [Python-Dev] bytes & bytearray

2015-01-19 Thread Greg Ewing
Guido van Rossum wrote: On Mon, Jan 19, 2015 at 11:43 AM, Paul Sokolovsky > wrote: b.lower_inplace() b.lower_i() Please don't go there. The use cases are too rare. And if you have such a use case, it's not too hard to do b[:] = b.lower() -- Greg _

Re: [Python-Dev] bytes & bytearray

2015-01-19 Thread Paul Sokolovsky
Hello, On Mon, 19 Jan 2015 14:03:20 -0800 Guido van Rossum wrote: > On Mon, Jan 19, 2015 at 11:43 AM, Paul Sokolovsky > wrote: > > > [...] > > So, suppose there's a requirement to support inplace operations > > (methods) on bytearray, what would be Pythonic way to implement it? > > > > Somethi

Re: [Python-Dev] bytes & bytearray

2015-01-19 Thread Guido van Rossum
On Mon, Jan 19, 2015 at 11:43 AM, Paul Sokolovsky wrote: > [...] > So, suppose there's a requirement to support inplace operations > (methods) on bytearray, what would be Pythonic way to implement it? > > Something like: > > b.lower_inplace() > b.lower_i() > > , or maybe > > import bytearray_ops

Re: [Python-Dev] bytes & bytearray

2015-01-19 Thread Paul Sokolovsky
Hello, On Mon, 19 Jan 2015 08:36:55 -0800 Ethan Furman wrote: > I was checking the documentation [1] to see where to put the new > information about bytes and bytearray %-formatting, and noticed > that /every/ operation that could modify a bytearray object in place > (e.g. center, capitalize, st

Re: [Python-Dev] bytes & bytearray

2015-01-19 Thread Antoine Pitrou
On Mon, 19 Jan 2015 12:01:36 -0500 "Eric V. Smith" wrote: > > I'd return a new copy (or, not implement it at all and let the default > machinery call __mod__, and do the assignment). That's the least > surprising to me, since the goal is to be compatible with 2.7's str > %-formatting. +1 for a c

Re: [Python-Dev] bytes & bytearray

2015-01-19 Thread Ethan Furman
On 01/19/2015 09:01 AM, Eric V. Smith wrote: > > I'd return a new copy (or, not implement it at all and let the default > machinery call __mod__, and do the assignment). That's the least > surprising to me, since the goal is to be compatible with 2.7's str > %-formatting. That certainly feels lik

Re: [Python-Dev] bytes & bytearray

2015-01-19 Thread Eric V. Smith
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 1/19/2015 11:36 AM, Ethan Furman wrote: > I was checking the documentation [1] to see where to put the new > information about bytes and bytearray %-formatting, and noticed > that /every/ operation that could modify a bytearray object in > place (e.

[Python-Dev] bytes & bytearray

2015-01-19 Thread Ethan Furman
I was checking the documentation [1] to see where to put the new information about bytes and bytearray %-formatting, and noticed that /every/ operation that could modify a bytearray object in place (e.g. center, capitalize, strip, etc.) instead returns a new copy. The section just prior to that