Advertisement
here2share

# xrange_vs_while.py

Apr 18th, 2021
843
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. # xrange_vs_while.py
  2.  
  3. from timeit import timeit
  4.  
  5. t = timeit(stmt='while i < 10 ** 7: i += 1',
  6.            setup='i = 0',
  7.            number=1)
  8. print t
  9.  
  10. t = timeit(stmt='for _ in xrange(0, 10 ** 7): pass',
  11.            number=1)
  12. print t
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement