Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In [1]: i = 4
- In [2]: timeit "Fizz" * (i % 3 == 0)
- 10000000 loops, best of 3: 35.6 ns per loop
- In [3]: timeit "Fizz" if i % 3 == 0 else ""
- 10000000 loops, best of 3: 34.2 ns per loop
- In [4]: i = 3
- In [5]: timeit "Fizz" * (i % 3 == 0)
- 10000000 loops, best of 3: 35.8 ns per loop
- In [6]: timeit "Fizz" if i % 3 == 0 else ""
- 10000000 loops, best of 3: 37.2 ns per loop
Advertisement
Add Comment
Please, Sign In to add comment