Skip to content

Instantly share code, notes, and snippets.

@mjpieters
Created July 29, 2014 17:57
Show Gist options
  • Save mjpieters/1b2c5b13536265e338ac to your computer and use it in GitHub Desktop.
Save mjpieters/1b2c5b13536265e338ac to your computer and use it in GitHub Desktop.
In [1]: from random import randint
In [2]: lines = [randint(0, 42) for _ in range(10000)]
In [3]: %%timeit
...: for _ in lines[::-1]: pass
...:
10000 loops, best of 3: 149 µs per loop
In [4]: %%timeit
for _ in reversed(lines): pass
...:
10000 loops, best of 3: 120 µs per loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment