Created
July 30, 2014 18:29
-
-
Save x/86892f50894cc2e46602 to your computer and use it in GitHub Desktop.
Named Tuple vs Dict Vs Tuple
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
| $ python -m timeit -s 'from collections import namedtuple; NT = namedtuple("NT", "a"); nt = NT(1)' 'nt.a' | |
| 10000000 loops, best of 3: 0.138 usec per loop | |
| /U/d/chartbeat(dev)(master)$ python -m timeit -s 'd = (1, )' 'd[0]' | |
| 10000000 loops, best of 3: 0.0409 usec per loop | |
| /U/d/chartbeat(dev)(master)$ python -m timeit -s 'd = {"a": 1}' 'd["a"]' | |
| 10000000 loops, best of 3: 0.0358 usec per loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment