example code:
def var1(ll):
s = sum(ll)
l = len(ll)
ave = float(s) / l
s = 0
for v in ll:
s += (v - ave) * (v - ave)
return math.sqrt(s/l)
def var2(ll):
s = sum(ll)
l = len(ll)
ave = float(s) / l
s = sum(map(lambda v: (v - ave) * (v - ave), ll))
return math.sqrt(s/l)
for above two examples, there is an obvious difference between these two examples. The one use lambda cost much more time than another when the list (ll) is large enough.
from my view, the cause is clear. because lambda is anonymous function and the invocation of the function cost much time then a statement I think.
and a suggestion for using lambda is to replace some simple function. but from the experiment above, the performance is bad.