Advertisement
here2share

# xrange_timeit.py

Dec 5th, 2019
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. # xrange_timeit.py
  2.  
  3. import timeit
  4.  
  5. def lookup_range():
  6.     return range(100000)
  7.  
  8. def lookup_xrange():
  9.     return xrange(100000)
  10.  
  11. print("Look up time in Range : {}".format(timeit.timeit('lookup_range()', 'from __main__ import lookup_range', number=1000)))
  12. print("Look up time in Xrange: {}".format(timeit.timeit('lookup_xrange()', 'from __main__ import lookup_xrange', number=1000)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement