Python3: on removing map, reduce, filter

Robert Kern rkern at
Sun Jan 9 16:06:19 CET 2005

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.


   def square(x):
       return x*x
   map(square, range(1000))


   [x*x for x in range(1000)]

Hint: function calls are expensive.

Robert Kern
rkern at

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

More information about the Python-list mailing list