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

2014-08-12 Thread Stephen J. Turnbull
Redirecting to python-ideas, so trimming less than I might. Chris Barker writes: > On Mon, Aug 11, 2014 at 11:07 PM, Stephen J. Turnbull > wrote: > > > I'm referring to removing the unnecessary information that there's a > > better way to do it, and simply raising an error (as in Python 3.

Re: [Python-Dev] Multiline with statement line continuation

2014-08-12 Thread Steven D'Aprano
On Tue, Aug 12, 2014 at 08:04:35AM -0500, Ian Cordasco wrote: > I think by introducing parentheses we are going to risk seriously > confusing users who may then try to write an assignment like > > a = (open('spam') as spam, open('eggs') as eggs) Seriously? If they try it, they will get a syntax

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

2014-08-12 Thread Nikolaus Rath
Chris Barker writes: > What I fail to see is why it's better to raise an exception and point users > to a better way, than to simply provide an optimization so that it's a mute > issue. > > The only justification offered here is that will teach people that summing > strings (and some other objects

Re: [Python-Dev] Multiline with statement line continuation

2014-08-12 Thread Devin Jeanpierre
On Tue, Aug 12, 2014 at 8:12 AM, Guido van Rossum wrote: > On Tue, Aug 12, 2014 at 3:43 AM, Devin Jeanpierre > wrote: >> The parentheses seem unnecessary/redundant/weird. Why not allow >> newlines in-between "with" and the terminating ":"? >> >> with open('foo') as foo, >>open('bar') as b

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

2014-08-12 Thread Stefan Richthofer
I know, I have nothing to decide here, since I'm no contributer and just a silent watcher on this list. However I just wanted to point out I fully agree with Chris Barker's position. Couldn't have stated it better. Performance should be interpreter implementation issue, not language issue.   >

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

2014-08-12 Thread Chris Barker
On Mon, Aug 11, 2014 at 11:07 PM, Stephen J. Turnbull wrote: > I'm referring to removing the unnecessary information that there's a > better way to do it, and simply raising an error (as in Python 3.2, > say) which is all a RealProgrammer[tm] should ever need! > I can't imagine anyone is sugges

Re: [Python-Dev] Multiline with statement line continuation

2014-08-12 Thread Georg Brandl
On 08/12/2014 06:57 PM, Armin Rigo wrote: > Hi, > > On 12 August 2014 01:08, Allen Li wrote: >> with (open('foo') as foo, >> open('bar') as bar, >> open('baz') as baz, >> open('spam') as spam, >> open('eggs') as eggs): >> pass > > +1. It's exa

Re: [Python-Dev] Multiline with statement line continuation

2014-08-12 Thread Armin Rigo
Hi, On 12 August 2014 01:08, Allen Li wrote: > with (open('foo') as foo, > open('bar') as bar, > open('baz') as baz, > open('spam') as spam, > open('eggs') as eggs): > pass +1. It's exactly the same grammar extension as for "from import" state

Re: [Python-Dev] Multiline with statement line continuation

2014-08-12 Thread Guido van Rossum
On Tue, Aug 12, 2014 at 3:43 AM, Devin Jeanpierre wrote: > I think this thread is probably Python-Ideas territory... > > On Mon, Aug 11, 2014 at 4:08 PM, Allen Li wrote: > > Currently, this works with explicit line continuation, but as all style > > guides favor implicit line continuation over e

Re: [Python-Dev] Multiline with statement line continuation

2014-08-12 Thread Ian Cordasco
On Tue, Aug 12, 2014 at 7:15 AM, Steven D'Aprano wrote: > On Tue, Aug 12, 2014 at 10:28:14AM +1000, Nick Coghlan wrote: >> On 12 Aug 2014 09:09, "Allen Li" wrote: >> > >> > This is a problem I sometimes run into when working with a lot of files >> > simultaneously, where I need three or more `wit

Re: [Python-Dev] Multiline with statement line continuation

2014-08-12 Thread Steven D'Aprano
On Tue, Aug 12, 2014 at 10:28:14AM +1000, Nick Coghlan wrote: > On 12 Aug 2014 09:09, "Allen Li" wrote: > > > > This is a problem I sometimes run into when working with a lot of files > > simultaneously, where I need three or more `with` statements: > > > > with open('foo') as foo: > >

Re: [Python-Dev] Multiline with statement line continuation

2014-08-12 Thread Devin Jeanpierre
I think this thread is probably Python-Ideas territory... On Mon, Aug 11, 2014 at 4:08 PM, Allen Li wrote: > Currently, this works with explicit line continuation, but as all style > guides favor implicit line continuation over explicit, it would be nice > if you could do the following: > > w

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

2014-08-12 Thread Armin Rigo
Hi all, The core of the matter is that if we repeatedly __add__ strings from a long list, we get O(n**2) behavior. For one point of view, the reason is that the additions proceed in left-to-right order. Indeed, sum() could proceed in a more balanced tree-like order: from [x0, x1, x2, x3, ...], r

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

2014-08-12 Thread Nick Coghlan
On 12 Aug 2014 11:21, "Chris Barker - NOAA Federal" wrote: > > Sorry for the bike shedding here, but: > >> The quadratic behaviour of repeated str summation is a subtle, silent error. > > OK, fair enough. I suppose it would be hard and ugly to catch those instances and raise an exception pointing