Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In [6]: i = 4
- In [7]: timeit "Fizz" * (i % 3 == 0)
- 10000000 loops, best of 3: 118 ns per loop
- In [8]: timeit "Fizz" if i % 3 == 0 else ""
- 10000000 loops, best of 3: 72 ns per loop
- In [9]: i = 3
- In [10]: timeit "Fizz" * (i % 3 == 0)
- 10000000 loops, best of 3: 110 ns per loop
- In [11]: timeit "Fizz" if i % 3 == 0 else ""
- 10000000 loops, best of 3: 72.2 ns per loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement