[Python-Dev] Disabling cyclic GC in timeit module (original) (raw)

Eli Bendersky eliben at gmail.com
Sat Oct 8 05:47:19 CEST 2011


Perhaps timeit should grow a macro-benchmark tool too? I find myself often using timeit to time macro-benchmarks simply because it's more convenient at the interactive interpreter than the alternatives.

Something like this idea perhaps? http://preshing.com/20110924/timing-your-code-using-pythons-with-statement

I have essentially the same snippet (with the addition of being able to provide names for timers, thus allowing to have several executing in the code and knowing which is which) lying in my toolbox for a long time now, and I find it very useful.

There's also an alternative approach, having a decorator that marks a function for benchmarking. David Beazley has one good example of this here: http://www.dabeaz.com/python3io/timethis.py

Eli



More information about the Python-Dev mailing list