one last point on this threadwe can also make use of python keyword-only arguments here to simplify the timer module' code as we learned in keywordonly arguments are ideal for configuration options such as our functions_reps argument they must be coded after and before *in the function headerand in function call they must be passed by keyword and appear before the *if used the following is keyword-only-based alternative to the prior module though simplerit compiles and runs under python onlynot xfile timer py ( only""same usage as timer pybut uses keyword-only default arguments instead of dict pops for simpler code no need to hoist range(out of tests in xalways generator in xand this can' run on ""import timesys timer time clock if sys platform[: ='winelse time time def total(func*pargs_reps= **kargs)start timer(for in range(_reps)ret func(*pargs**kargselapsed timer(start return (elapsedretdef bestof(func*pargs_reps= **kargs)best * for in range(_reps)start timer(ret func(*pargs**kargselapsed timer(start if elapsed bestbest elapsed return (bestretdef bestoftotal(func*pargs_reps = **kargs)return min(total(func*pargs**kargsfor in range(_reps )this version is used the same way as the prior version and produces identical resultsso won' relist its outputs on the same tests hereexperiment on your own as you wish if you dopay attention to the argument ordering rules in calls former bes tof that ran totalfor instancecalled like this(elapsedrettotal(func*pargs_reps= **kargssee for more on keyword-only arguments in xthey can simplify code for configurable tools like this one but are not backward compatible with pythons if you want to compare and speedor support programmers using either python linethe prior version is likely better choice also keep in mind that for trivial functions like some of those tested for the prior versionthe costs of the timer' code may sometimes be as significant as those of simple timed functionso you should not take timer results too absolutely the timer' results can timing iteration alternatives