list-comprehension and map question (simple)

Robert Kern rkern at
Mon Mar 28 17:04:50 CEST 2005

runsun pan wrote:
> I remember reading somewhere that the map, filter, reduce are much
> faster than list comp.

It depends.

   map(float, some_list_of_numbers)

is going to be faster than

   [float(x) for x in some_list_of_numbers]


   map(lambda x,y: x+y, xs, ys)

is going to be slower than

   import itertools
   [x+y for x,y in itertools.izip(xs, ys)]

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