callable objects instead of stringsaccept automatic loop countsand use class-based techniques and additional command-line switches and api argument options we don' have space to show here--consult python' library manual for more detailsc:\codepy - import timeit timeit timeit(stmt='[ * for in range( )]'number= total time timeit timer(stmt='[ * for in range( )]'timeit( class api timeit repeat(stmt='[ * for in range( )]'number= repeat= [ def testcase() [ * for in range( )callable objects or code strings min(timeit repeat(stmt=testcasenumber= repeat= ) benchmark module and scripttimeit rather than go into more details on this modulelet' study program that deploys it to time both coding alternatives and python versions the following filepybench pyis set up to time set of statements coded in scripts that import and use itunder either the version running its code or all python versions named in list it uses some application-level tools described ahead because it mostly applies ideas we've already learned and is amply documentedthoughi' going to list this as mostly self-study materialand an exercise in reading python code ""pybench pytest speed of one or more pythons on set of simple code-string benchmarks functionto allow stmts to vary this system itself runs on both and xand may spawn both uses timeit to test either the python running this script by api callsor set of pythons by reading spawned command-line outputs (os popenwith python' - flag to find timeit on module search path replaces $listif with list(around generators for and an empty string for xso does same work as in command-line mode onlymust split multiline statements into one separate quoted argument per line so all will be run (else might run/time first line only)and replace all \ in indentation with spaces for uniformity caveatscommand-line mode (onlymay fail if test stmt embeds double quotesquoted stmt string is incompatible with shell in generalor command-line exceeds length limit on platform' shell--use api call mode or homegrown timerdoes not yet support setup statementas istime of all statements in the test stmt are charged to the total time ""timing iterations and pythons with timeit