Created
October 12, 2011 16:48
-
-
Save 9thbit/1281789 to your computer and use it in GitHub Desktop.
Benchmarks for popping from a python list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Benchmarks for popping from a list | |
# If you want to always pop the first element of a list, then don't use pop(0) | |
# Instead reverse the list once and use pop. | |
python -m timeit "a=range(1000000)" "a.reverse()" "while a: a.pop()" | |
python -m timeit "a=range(1000000)" "while a: a.pop(0)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment