Re: [Python-Dev] sum(...) limitation

2014-08-09 Thread Stephen J. Turnbull
Alexander Belopolsky writes: Why have builtin sum at all if its use comes with so many caveats? Because we already have it. If the caveats had been known when it was introduced, maybe it wouldn't have been. The question is whether you can convince python-dev that it's worth changing the

Re: [Python-Dev] sum(...) limitation

2014-08-09 Thread Paul Moore
On 9 August 2014 06:08, Steven D'Aprano st...@pearwood.info wrote: py with Stopwatch(): ... sum(carray) # carray is a numpy array of 7500 floats. ... 11250.0 time taken: 52.659770 seconds py with Stopwatch(): ... numpy.sum(carray) ... 11250.0 time taken: 0.161263

[Python-Dev] os.walk() is going to be *fast* with scandir

2014-08-09 Thread Ben Hoyt
Just thought I'd share some of my excitement about how fast the all-C version [1] of os.scandir() is turning out to be. Below are the results of my scandir / walk benchmark run with three different versions. I'm using an SSD, which seems to make it especially faster than listdir / walk. Note that

Re: [Python-Dev] sum(...) limitation

2014-08-09 Thread Alexander Belopolsky
On Sat, Aug 9, 2014 at 3:08 AM, Stephen J. Turnbull step...@xemacs.org wrote: All the suggestions I've seen so far are (IMHO, YMMV) just as ugly as the present situation. What is ugly about allowing strings? CPython certainly has a way to to make sum(x, '') at least as efficient as y='';for

Re: [Python-Dev] sum(...) limitation

2014-08-09 Thread Alexander Belopolsky
On Sat, Aug 9, 2014 at 2:02 PM, Alexander Belopolsky alexander.belopol...@gmail.com wrote: y='';for in in x; y+= x Should have been y='' for i in x; y += i ___ Python-Dev mailing list Python-Dev@python.org

[Python-Dev] class Foo(object) vs class Foo: should be clearly explained in python 2 and 3 doc

2014-08-09 Thread John Yeuk Hon Wong
Hi. Referring to my discussion on [1] and then on #python this afternoon. A little background would help people to understand where this was coming from. 1. I write Python 2 code and have done zero Python-3 specific code. 2. I have always been using class Foo(object) so I do not know the new

Re: [Python-Dev] sum(...) limitation

2014-08-09 Thread Alexander Belopolsky
On Sat, Aug 9, 2014 at 1:08 AM, Steven D'Aprano st...@pearwood.info wrote: We wouldn't be having these interminable arguments about using sum() to concatenate strings (and lists, and tuples) if the operator was used for concatenation and + was only used for numeric addition. But we would

Re: [Python-Dev] class Foo(object) vs class Foo: should be clearly explained in python 2 and 3 doc

2014-08-09 Thread Terry Reedy
On 8/9/2014 2:44 PM, John Yeuk Hon Wong wrote: Hi. Referring to my discussion on [1] and then on #python this afternoon. A little background would help people to understand where this was coming from. 1. I write Python 2 code and have done zero Python-3 specific code. 2. I have always been

Re: [Python-Dev] sum(...) limitation

2014-08-09 Thread Devin Jeanpierre
On Sat, Aug 9, 2014 at 12:20 PM, Alexander Belopolsky alexander.belopol...@gmail.com wrote: On Sat, Aug 9, 2014 at 1:08 AM, Steven D'Aprano st...@pearwood.info wrote: We wouldn't be having these interminable arguments about using sum() to concatenate strings (and lists, and tuples) if the

Re: [Python-Dev] class Foo(object) vs class Foo: should be clearly explained in python 2 and 3 doc

2014-08-09 Thread Steven D'Aprano
On Sat, Aug 09, 2014 at 02:44:10PM -0400, John Yeuk Hon Wong wrote: Hi. Referring to my discussion on [1] and then on #python this afternoon. A little background would help people to understand where this was coming from. 1. I write Python 2 code and have done zero Python-3 specific

Re: [Python-Dev] class Foo(object) vs class Foo: should be clearly explained in python 2 and 3 doc

2014-08-09 Thread Chris Angelico
On Sun, Aug 10, 2014 at 10:44 AM, Steven D'Aprano st...@pearwood.info wrote: Looking at your comment here: [1]: https://news.ycombinator.com/item?id=8154471 there is a reply from zeckalpha, who says: Actually, leaving out `object` is the preferred convention for Python 3, as they

Re: [Python-Dev] os.walk() is going to be *fast* with scandir

2014-08-09 Thread Antoine Pitrou
Le 09/08/2014 12:43, Ben Hoyt a écrit : Just thought I'd share some of my excitement about how fast the all-C version [1] of os.scandir() is turning out to be. Below are the results of my scandir / walk benchmark run with three different versions. I'm using an SSD, which seems to make it

Re: [Python-Dev] os.walk() is going to be *fast* with scandir

2014-08-09 Thread Nick Coghlan
On 10 August 2014 13:20, Antoine Pitrou anto...@python.org wrote: Le 09/08/2014 12:43, Ben Hoyt a écrit : Just thought I'd share some of my excitement about how fast the all-C version [1] of os.scandir() is turning out to be. Below are the results of my scandir / walk benchmark run with