Passing function objects to timeit

Peter Otten __peter__ at web.de
Tue Apr 1 08:18:37 EDT 2008


George Sakkis wrote:

> I'm afraid that the taken approach is worse than your patch. For one
> thing, it allows only zero-arg functions. Of course one can work
> around it by passing "lambda: f(...)" but that's adding extra overhead
> which can be measurable for small fast functions. Even if passing
> *args and **kwds to a Timer is allowed, that's still going to be
> slower (because of tuple unpacking and whatnot) as Steven's attempt
> above showed.
> 
> I think it's at least worth bringing this to the attention of the
> developers.

I decided to give it a try:

http://bugs.python.org/issue2527

Peter



More information about the Python-list mailing list