August 2018
Intermediate to advanced
366 pages
10h 14m
English
The timeit module provides a bunch of utilities to time a function or whole script:
>>> import timeit >>> print( ... timeit.timeit(function1) ... ) 10.132873182068579 >>> print( ... timeit.timeit(function2) ... ) 5.13165780401323
From the reported timing, we know that function2 is twice as fast as function1.