Top "Timeit" questions

A Python built-in module for measuring execution time of small code snippets.

Inconsistency between %time and %timeit in IPython

I am confronted to a weird situation that I can't explain. Here is my test timing the generation of a …

python ipython timeit
Why is it slower to iterate over a small string than a small list?

I was playing around with timeit and noticed that doing a simple list comprehension over a small string took longer …

python performance cpython timeit python-internals
How to time Django queries

I've always used Python's timeit library to time my little Python programs. Now I'm developing a Django app and I …

django timeit
How can I capture return value with Python timeit module?

Im running several machine learning algorithms with sklearn in a for loop and want to see how long each of …

python python-2.7 scikit-learn timeit
How to use timeit when timing a function

Let me start off by saying I know almost nothing about python but have to write a program in three …

python timeit
timeit ValueError: stmt is neither a string nor callable

I played with timeit in Python, got a weird problem. I define a simple function add. timeit works when I …

python callable timeit
IPython %timeit what is loop and iteration in the options?

I am wondering about the %timeit command in IPython From the docs: %timeit [-n<N> -r<R&…

python ipython timeit
What do `ns` and `us` stand for in `timeit` result?

I was trying to compare performance of two statements with timeit, and the results are something like: 100 loops, best of 3: 100 …

python timeit
Why is if True slower than if 1?

Why is if True slower than if 1 in Python? Shouldn't if True be faster than if 1? I was trying to …

python performance if-statement boolean timeit
Can you capture the output of ipython's magic methods? (timeit)

I want to capture and plot the results from 5 or so timeit calls with logarithmically increasing sizes of N to …

ipython ipython-notebook timeit