Created
February 19, 2015 09:54
-
-
Save davidwtbuxton/cc836e21c16d44e87c87 to your computer and use it in GitHub Desktop.
Python: using dict.update() is a lot slower than just setting a single key.
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 'd = {}' 'd.update({"key": "value"})' | |
1000000 loops, best of 3: 0.293 usec per loop | |
$ python -m timeit -s 'd = {}' 'd["key"] = "value"' | |
10000000 loops, best of 3: 0.0433 usec per loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment