Why is lambda so slow?

Erik Max Francis max at alcyone.com
Mon Jun 9 18:59:50 EDT 2003


Tyler Eaves wrote:

> Seems pretty slow to me.
> 
> Doing that with a trandional function is MUCH faster.

I think if you defined what you meant by "traditional function" we could
get to the heart of the matter pretty quickly.

Using lambda x, y: x + y is going to be slower than using using
operator.add, since the former is an all-Python solution but the latter
is implemented in C.  But using f = lambda x, y: x = y isn't going to be
much slower than def f(x, y): return x + y.

-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ You are free and that is why you are lost.
\__/  Franz Kafka




More information about the Python-list mailing list