fastset set([( )( )]timing the results under python so how did we do on the optimization front this timeagainguesses aren' usually good enoughthough algorithmic complexity seems compelling piece of evidence here to be sureexample - codes script to compare set class performance it reuses the timer module of example - used earlier to compare stacks (our code may implement different objectsbut it doesn' warp timeexample - pp \dstruct\basic\settime py "compare set alternatives performanceimport timersys import setfastset def setops(class) class(range( ) class(range( ) class(range( ) class(range( )for in range( ) xrange okay -integer set -integer set intersections unions if __name__ ='__main__'rept int(sys argv[ ]print('set ='timer test(reptsetopsset set)print('fastset =>'timer test(reptsetopsfastset set)the setops function makes four sets and combines them with intersection and union operators five times command-line argument controls the number of times this whole process is repeated more accuratelyeach call to setops makes set instances ( [ ( )]and runs the intersect and union methods times each ( in the for loop' body the performance improvement is equally dramatic this time aroundon the same windows laptop under python :\pp \dstruct\basicpython settime py set = fastset = :\pp \dstruct\basicpython settime py set = fastset = :\pp \dstruct\basicpython settime py set = fastset = implementing sets