may differ in resolutiontrytimer time perf_counter or process_time except attributeerrortimer time clock if sys platform[: ='winelse time time if were writing this book for python readers onlyi' use the new and apparently improved calls hereand you should in your work too if they apply to you the newer calls won' work for users of any other pythonsthoughand that' still the majority of the python world today it would be easier to pretend that the past doesn' matterbut that would not only be evasive of realityit might also be just plain rude timing script nowto time iteration tool speed (our original goal)run the following script--it uses the timer module we wrote to time the relative speeds of the list construction techniques we've studiedfile timeseqs py "test the relative speed of iteration tool alternatives import systimer reps repslist list(range(reps)import timer functions hoist outlist in both / def forloop()res [for in repslistres append(abs( )return res def listcomp()return [abs(xfor in repslistdef mapcall()return list(map(absrepslist)return map(absrepslistuse list(here in onlydef genexpr()return list(abs(xfor in repslistlist(required to force results def genfunc()def gen()for in repslistyield abs(xreturn list(gen()list(required to force results print(sys versionfor test in (forlooplistcompmapcallgenexprgenfunc)(bestof(totalresult)timer bestoftotal( test the benchmarking interlude