operation and uses the same repetition counts as pybench_cases pyc:\codepy - timeseqs py ( :bd afb ebf sep : : [msc bit (amd )forloop =[ listcomp =[ mapcall =[ genexpr =[ genfunc =[ :\codepy - pybench_cases py ( :bd afb ebf sep : : [msc bit (amd ) ['[ * for in range( )]' ['res=[]\nfor in range( )res append( * )' ['list(map(lambda xx * range( )))' ['list( * for in range( ))' [" 'spam \nx [ [ifor in range( )]" [" '?'\nfor in range( ) +'?'"the homegrown timer results are very similar to the pybench-based results of this section that use timeitthough it' not entirely apples-to-apples--the homegrown timerbased timeseqs py incurs function call per its middle totals loop and slight overhead in best of logic of the timer itselfbut also uses prebuilt list instead of range generator in its inner loopwhich seems to make it slightly net faster on comparable tests (and ' call this example "sanity check,but ' not sure the term applies in benchmarking!room for improvementsetup like most softwarethis section' program is open-ended and could be expanded arbitrarily as one examplethe files pybench py and pybench _cases py in the book' examples package add support for timeit' setup statement option described earlierin both api call and command-line modes this feature was omitted initially for brevityand franklybecause my tests didn' seem to require it--timing more code gives more complete picture when comparing pythonsand setup actions cost the same when timing alternatives on single python even soit' sometimes useful to provide setup code that is run once in the tested code' scopebut whose time is not charged to the statement' total-- module importobject initializationor helper function definitionfor example won' list these two files in wholebut here are their important varying bits as an example of software evolution at work--as for the test statementthe setup code statement is passed as is in api call modebut is split and space-indented in command-line mode and passed with one - argument per line ("$listif isn' used because setup code is not timed)pybench py def runner(stmtspythons=nonetracecmd=false) the benchmarking interlude