Re: removing list comprehensions in Python 3.0

2005-07-13 Thread Steven Bethard
Edvard Majakari wrote: > Steven Bethard <[EMAIL PROTECTED]> writes: > >>$ python -m timeit "for x in (i for i in xrange(10)): y = x" >>10 loops, best of 3: 4.75 usec per loop > > Yowza! One of the features I really liked in Perl has shored Python island > somewhere in the 2.4'ies, it seems[1]

Re: removing list comprehensions in Python 3.0

2005-07-13 Thread Edvard Majakari
Steven Bethard <[EMAIL PROTECTED]> writes: > $ python -m timeit "for x in (i for i in xrange(10)): y = x" > 10 loops, best of 3: 4.75 usec per loop Yowza! One of the features I really liked in Perl has shored Python island somewhere in the 2.4'ies, it seems[1]. Thanks for the tip! PS. In cas

Re: removing list comprehensions in Python 3.0

2005-07-12 Thread Steven Bethard
Steven Bethard wrote: > py> def ge(items): > ... return (item for item in items if item) > ... Bengt Richter wrote: > >>> dis.dis(ge) >2 0 LOAD_CONST 1 ( expression> at 02EE4FA0, file "", line 2>) >3 MAKE_FUNCTION0 >6 LOA

Re: removing list comprehensions in Python 3.0

2005-07-10 Thread EP
> Well, I want to offer a more radical proposal: why not free squared > braces from the burden of representing lists at all? It should be > sufficient to write > > >>> list() > list() > >From a visual comprehenison point of view, I would assert that the square form >[] is much easier on the

Re: removing list comprehensions in Python 3.0

2005-07-10 Thread Bengt Richter
On Sat, 09 Jul 2005 22:32:22 -0600, Steven Bethard <[EMAIL PROTECTED]> wrote: >Raymond Hettinger wrote: >> [Steven Bethard] >> >>>I would hope that in Python 3.0 list comprehensions and generator >>>expressions would be able to share a large amount of implementation, and >>>thus that the speed di

Re: removing list comprehensions in Python 3.0

2005-07-09 Thread Steven Bethard
Raymond Hettinger wrote: > [Steven Bethard] > >>I would hope that in Python 3.0 list comprehensions and generator >>expressions would be able to share a large amount of implementation, and >>thus that the speed differences would be much smaller. But maybe not... > > Looking under the hood, you w

Re: removing list comprehensions in Python 3.0

2005-07-09 Thread Raymond Hettinger
[Raymond Hettinger] > > It is darned inconvenient to get an iterator when you really > > need a list, when you want to slice the result, when you want to see a > > few elements through repr(), and when you need to loop over the > > contents more than once. [George Sakkis] > Similar arguments can b

Re: removing list comprehensions in Python 3.0

2005-07-09 Thread Raymond Hettinger
[Steven Bethard] > I would hope that in Python 3.0 list comprehensions and generator > expressions would be able to share a large amount of implementation, and > thus that the speed differences would be much smaller. But maybe not... Looking under the hood, you would see that the implementations

Re: removing list comprehensions in Python 3.0

2005-07-09 Thread Steven Bethard
Raymond Hettinger wrote: > The root of this discussion has been the observation that a list > comprehension can be expressed in terms of list() and a generator > expression. As George Sakkis already noted, the root of the discussion was actually the rejection of the dict comprehensions PEP. > Ho

Re: removing list comprehensions in Python 3.0

2005-07-09 Thread Steven Bethard
Devan L wrote: import timeit t1 = timeit.Timer('list(i for i in xrange(10))') t1.timeit() > > 27.267753024476576 > t2 = timeit.Timer('[i for i in xrange(10)]') t2.timeit() > > 15.050426800054197 > t3 = timeit.Timer('list(i for i in xrange(100))') t3.timeit() > > 117

Re: removing list comprehensions in Python 3.0

2005-07-09 Thread John Roth
"George Sakkis" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > It's funny how one of the > arguments for removing lambda -- you can do the same by defining a > named function -- does not apply for list comprehensions. Which is a point a number of people have made many times, with

Re: removing list comprehensions in Python 3.0

2005-07-09 Thread George Sakkis
"Raymond Hettinger" <[EMAIL PROTECTED]> wrote: > In all probability, both list comprehensions and generator expressions > will be around in perpetuity. List comps have been a very successful > language feature. > > The root of this discussion has been the observation that a list > comprehension c

Re: removing list comprehensions in Python 3.0

2005-07-09 Thread John Roth
"Raymond Hettinger" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > In all probability, both list comprehensions and generator expressions > will be around in perpetuity. List comps have been a very successful > language feature. > > The root of this discussion has been the observat

Re: removing list comprehensions in Python 3.0

2005-07-09 Thread Bengt Richter
On Sat, 09 Jul 2005 10:16:17 -0400, Peter Hansen <[EMAIL PROTECTED]> wrote: >Bengt Richter wrote: >> On Fri, 08 Jul 2005 22:29:30 -0600, Steven Bethard <[EMAIL PROTECTED]> wrote: >>>(1) There's no reason to get uncomfortable even if they're removed. >>>You'd just replace [] with list(). >> >> So

Re: removing list comprehensions in Python 3.0

2005-07-09 Thread Raymond Hettinger
In all probability, both list comprehensions and generator expressions will be around in perpetuity. List comps have been a very successful language feature. The root of this discussion has been the observation that a list comprehension can be expressed in terms of list() and a generator expressi

Re: removing list comprehensions in Python 3.0

2005-07-09 Thread Peter Hansen
Bengt Richter wrote: > On Fri, 08 Jul 2005 22:29:30 -0600, Steven Bethard <[EMAIL PROTECTED]> wrote: >>(1) There's no reason to get uncomfortable even if they're removed. >>You'd just replace [] with list(). > > So list(1, 2, 3) will be the same as [1, 2, 3] ?? No, the discussion is about list c

Re: removing list comprehensions in Python 3.0

2005-07-08 Thread Kay Schluehr
Leif K-Brooks schrieb: > Kay Schluehr wrote: > list.from_str("abc") > > > > list("a", "b", "c" ) > > > I assume we'll also have list.from_list, list.from_tuple, > list.from_genexp, list.from_xrange, etc.? One might unify all those factory functions into a single list.from_iter that dispatches

Re: removing list comprehensions in Python 3.0

2005-07-08 Thread Ron Adam
Leif K-Brooks wrote: > Kay Schluehr wrote: > >list.from_str("abc") >> >>list("a", "b", "c" ) > > > > I assume we'll also have list.from_list, list.from_tuple, > list.from_genexp, list.from_xrange, etc.? List from list isn't needed, nor list from tuple. That's what the * is for. And for t

Re: removing list comprehensions in Python 3.0

2005-07-08 Thread Bengt Richter
On Fri, 08 Jul 2005 22:29:30 -0600, Steven Bethard <[EMAIL PROTECTED]> wrote: >Dennis Lee Bieber wrote: >> On Fri, 08 Jul 2005 16:07:50 -0600, Steven Bethard >> <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: >> >>>I only searched a few relatively recent threads in c.l.py, so the

Re: removing list comprehensions in Python 3.0

2005-07-08 Thread Devan L
>>> import timeit >>> t1 = timeit.Timer('list(i for i in xrange(10))') >>> t1.timeit() 27.267753024476576 >>> t2 = timeit.Timer('[i for i in xrange(10)]') >>> t2.timeit() 15.050426800054197 >>> t3 = timeit.Timer('list(i for i in xrange(100))') >>> t3.timeit() 117.61078097914682 >>> t4 = timeit.Time

Re: removing list comprehensions in Python 3.0

2005-07-08 Thread Leif K-Brooks
Kay Schluehr wrote: list.from_str("abc") > > list("a", "b", "c" ) I assume we'll also have list.from_list, list.from_tuple, list.from_genexp, list.from_xrange, etc.? -- http://mail.python.org/mailman/listinfo/python-list

Re: removing list comprehensions in Python 3.0

2005-07-08 Thread Ron Adam
Kay Schluehr wrote: > > Leif K-Brooks schrieb: > >>Kay Schluehr wrote: >> >>>Well, I want to offer a more radical proposal: why not free squared >>>braces from the burden of representing lists at all? It should be >>>sufficient to write >>> >>> >>list() >>> >>>list() >> >>So then what would t

Re: removing list comprehensions in Python 3.0

2005-07-08 Thread Steven Bethard
Dennis Lee Bieber wrote: > On Fri, 08 Jul 2005 16:07:50 -0600, Steven Bethard > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > >>I only searched a few relatively recent threads in c.l.py, so there are >>probably more, but it looks to me like the final decision will have to >>

Re: removing list comprehensions in Python 3.0

2005-07-08 Thread Kay Schluehr
Leif K-Brooks schrieb: > Kay Schluehr wrote: > > Well, I want to offer a more radical proposal: why not free squared > > braces from the burden of representing lists at all? It should be > > sufficient to write > > > list() > > > > list() > > So then what would the expression list('foo') mean

Re: removing list comprehensions in Python 3.0

2005-07-08 Thread Steven Bethard
Devan L wrote: > List comprehensions are faster than generator comprehensions for > iterating over smaller sequences. Could you give me an example? For the simple one below, the generator expression was faster: $ python -m timeit "for x in (i for i in xrange(10)): y = x" 10 loops, best of 3

Re: removing list comprehensions in Python 3.0

2005-07-08 Thread Steven Bethard
Kay Schluehr wrote: > Well, I want to offer a more radical proposal: why not free squared > braces from the burden of representing lists at all? It should be > sufficient to write > list() > list() > > After being free one can use them for other purposes e.g. replacing the > ugly @ decorator

Re: removing list comprehensions in Python 3.0

2005-07-08 Thread Devan L
List comprehensions are faster than generator comprehensions for iterating over smaller sequences. -- http://mail.python.org/mailman/listinfo/python-list

Re: removing list comprehensions in Python 3.0

2005-07-08 Thread Leif K-Brooks
Kay Schluehr wrote: > Well, I want to offer a more radical proposal: why not free squared > braces from the burden of representing lists at all? It should be > sufficient to write > list() > > list() So then what would the expression list('foo') mean? Would it be equivalent to ['foo'] (if so

Re: removing list comprehensions in Python 3.0

2005-07-08 Thread Kay Schluehr
Steven Bethard schrieb: > I think the jury's still out on this one: > > * Alex Martelli expects list comprehensions to be removed. [1] > * Robert Kern wants list comprehensions removed. [2] > * Raymond Hettinger encourages continued use of list comprehensions [3] > * Jeremy Bowers thinks list comp