Do not use mixed units in timeit output
Author: maxnoeCreated Jul 25, 2024Updated Aug 16, 2026
Timeit reports mean and std dev in different units in some cases, e.g. the mean is in a different order of magnitude from the std.
In [1]: from time import sleep
In [2]: %timeit sleep(0.001)
1.08 ms ± 11.4 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)This is pretty hard to parse and violates best practices of reporting value and uncertainty in the same units.
The preferred output would be:
In [1]: from time import sleep
In [2]: %timeit sleep(0.001)
1.080 ± 0.011 ms per loop (mean ± std. dev. of 7 runs, 1,000 loops each)Source: ipython/ipython