Skip to content

Instantly share code, notes, and snippets.

@wozozo
Created February 9, 2010 04:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wozozo/298907 to your computer and use it in GitHub Desktop.
Save wozozo/298907 to your computer and use it in GitHub Desktop.
#!/opt/local/bin/python
# -*- coding: utf-8 -*-
import timeit
t = timeit.Timer(stmt="dict(a='aaaaa',b='bbbbb',c='ccccc',d='ddddd',e='eeeee')")
for i in range(5):
print 'dict: %s' % t.timeit(number=1000000)
t = timeit.Timer(stmt="{'a':'aaaaa','b':'bbbbb','c':'ccccc','d':'ddddd','e':'eeeee'}")
for i in range(5):
print '{} : %s' % t.timeit(number=1000000)
# dict: 0.804573059082
# dict: 0.791139125824
# dict: 0.787436008453
# dict: 0.784868001938
# dict: 0.791957855225
# {} : 0.305773973465
# {} : 0.306412935257
# {} : 0.305012226105
# {} : 0.304980993271
# {} : 0.30428814888
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment