Re: Python3: on removing map, reduce, filter

2005-01-10 Thread David M. Cooke
Steven Bethard [EMAIL PROTECTED] writes: Some timings to verify this: $ python -m timeit -s def square(x): return x*x map(square, range(1000)) 1000 loops, best of 3: 693 usec per loop $ python -m timeit -s [x*x for x in range(1000)] 1000 loops, best of 3: 0.0505 usec per loop Maybe you

Re: Python3: on removing map, reduce, filter

2005-01-10 Thread Steven Bethard
David M. Cooke wrote: Steven Bethard [EMAIL PROTECTED] writes: Some timings to verify this: $ python -m timeit -s def square(x): return x*x map(square, range(1000)) 1000 loops, best of 3: 693 usec per loop $ python -m timeit -s [x*x for x in range(1000)] 1000 loops, best of 3: 0.0505 usec per

Re: Python3: on removing map, reduce, filter

2005-01-10 Thread Terry Reedy
Andrey Tatarinov [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] How does GvR suggestions on removing map(), reduce(), filter() While GvR *might* prefer removing them completely on any given day, I think moving them to a functional module, as others have suggested and requested, is

Re: Python3: on removing map, reduce, filter

2005-01-10 Thread Nick Coghlan
Terry Reedy wrote: Andrey Tatarinov [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] How does GvR suggestions on removing map(), reduce(), filter() While GvR *might* prefer removing them completely on any given day, I think moving them to a functional module, as others have suggested

Python3: on removing map, reduce, filter

2005-01-09 Thread Andrey Tatarinov
Hi. How does GvR suggestions on removing map(), reduce(), filter() correlate with the following that he wrote himself (afaik): http://www.python.org/doc/essays/list2str.html ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread Paul Rubin
Andrey Tatarinov [EMAIL PROTECTED] writes: How does GvR suggestions on removing map(), reduce(), filter() correlate with the following that he wrote himself (afaik): http://www.python.org/doc/essays/list2str.html I think that article was written before list comprehensions were added to

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread Andrey Tatarinov
Paul Rubin wrote: How does GvR suggestions on removing map(), reduce(), filter() correlate with the following that he wrote himself (afaik): http://www.python.org/doc/essays/list2str.html I think that article was written before list comprehensions were added to Python. anyway list comprehensions

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread Paul Rubin
Andrey Tatarinov [EMAIL PROTECTED] writes: anyway list comprehensions are just syntaxic sugar for for var in list: smth = ... res.append(smth) (is that correct?) I would expect lc's to work more like map does. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread Robert Kern
Andrey Tatarinov wrote: anyway list comprehensions are just syntaxic sugar for for var in list: smth = ... res.append(smth) (is that correct?) so there will be no speed gain, while map etc. are C-implemented It depends. Try def square(x): return x*x map(square, range(1000))

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread Roman Suzi
On Sun, 9 Jan 2005, Paul Rubin wrote: Andrey Tatarinov [EMAIL PROTECTED] writes: I hope there will be from __past__ import functional_paradigma in Python 3 ;-) And, also, what is the best way to replace reduce() ? Sincerely yours, Roman Suzi -- [EMAIL PROTECTED] =\= My AI powered by

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread Steve Holden
Andrey Tatarinov wrote: Hi. How does GvR suggestions on removing map(), reduce(), filter() correlate with the following that he wrote himself (afaik): http://www.python.org/doc/essays/list2str.html ? It promotes the sensible realization that when optimization is the goal code may well tend to

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread Andrey Tatarinov
Steve Holden wrote: Andrey Tatarinov wrote: Hi. How does GvR suggestions on removing map(), reduce(), filter() correlate with the following that he wrote himself (afaik): http://www.python.org/doc/essays/list2str.html And note that the summary in the conclusiogn BEGINS with Rule number one:

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread Robert Kern
Andrey Tatarinov wrote: Steve Holden wrote: Andrey Tatarinov wrote: Hi. How does GvR suggestions on removing map(), reduce(), filter() correlate with the following that he wrote himself (afaik): http://www.python.org/doc/essays/list2str.html And note that the summary in the conclusiogn BEGINS

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread Steven Bethard
Robert Kern wrote: Andrey Tatarinov wrote: anyway list comprehensions are just syntaxic sugar for for var in list: smth = ... res.append(smth) (is that correct?) so there will be no speed gain, while map etc. are C-implemented It depends. Try def square(x): return x*x

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread John Roth
Andrey Tatarinov [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi. How does GvR suggestions on removing map(), reduce(), filter() correlate with the following that he wrote himself (afaik): http://www.python.org/doc/essays/list2str.html This is fairly old. Note that the fastest

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread John Machin
Steven Bethard wrote: Note that list comprehensions are also C-implemented, AFAIK. Rather strange meaning attached to C-implemented. The implementation generates the code that would have been generated had you written out the loop yourself, with a speed boost (compared with the fastest DIY

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread beliavsky
Steve Holden wrote: def square(x): return x*x map(square, range(1000)) versus [x*x for x in range(1000)] Hint: function calls are expensive. $ python -m timeit -s def square(x): return x*x map(square, range(1000)) 1000 loops, best of 3: 693 usec per loop $ python -m timeit

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread Steven Bethard
[EMAIL PROTECTED] wrote: Steve Bethard wrote: Robert Kern wrote: def square(x): return x*x map(square, range(1000)) versus [x*x for x in range(1000)] Hint: function calls are expensive. $ python -m timeit -s def square(x): return x*x map(square, range(1000)) 1000 loops, best of 3: 693