Advertisement
duquesne9

timeit basic

Oct 13th, 2020 (edited)
2,076
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. import timeit
  2. # def inside():
  3. s = '''
  4. new={}
  5. with open('1.txt', 'r') as f:
  6.    sequence = f.read()
  7.    for i in sequence:
  8.        new[i]=i
  9. '''
  10.  
  11. # def outside():
  12. p = '''
  13. new={}
  14. with open('1.txt', 'r') as f:
  15.    sequence = f.read()
  16. for i in sequence:
  17.    new[i]=i
  18. '''
  19.  
  20. print(timeit.timeit(stmt=s, number=1_000))
  21. print(timeit.timeit(stmt=p, number=1_000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement