The secrets of operator.add

Alex Martelli aleaxit at yahoo.com
Fri Dec 8 18:37:03 CET 2000


"Jacek Generowicz" <jmg at ecs.soton.ac.uk> wrote in message
news:g08zpq51vy.fsf at scumbag.ecs.soton.ac.uk...
    [snip]
> It looks as if multiple calls to operator.add are avoided somehow
> . . . or am I failing to understand the profiler's output ?

I think the profiler may be inserting its tracefunction in some
places and not others, thus perhaps distorting measurement.


> Is there a way of getting similar advantages in
>
> run ('map(lambda x:x+1, range(N))')  ?
>
> Is there a Python way of currying add?

There are several, e.g.:

def curry_add(n):
    def curried_add(x,n=n):
        return x+n
    return curried_add

but I doubt the actual performance will be noticeably different.


Alex






More information about the Python-list mailing list