Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def using_builtins():
- x = range(10000)
- a = min(x)
- b = max(x)
- avg = sum(x) / len(x)
- def manual_search():
- x = range(10000)
- a = x[0]
- b = x[0]
- total = 0
- for item in x:
- if item < a: a = item
- if item > b: b = item
- total += item
- avg = total / len(x)
- import timeit
- print timeit.timeit(using_builtins, number=10000)
- print timeit.timeit(manual_search, number=10000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement