Skip to content

Instantly share code, notes, and snippets.

@pengelana
Created November 30, 2018 17:46
Show Gist options
  • Save pengelana/f6d29b76285066f7def4a11f8d20fdb3 to your computer and use it in GitHub Desktop.
Save pengelana/f6d29b76285066f7def4a11f8d20fdb3 to your computer and use it in GitHub Desktop.
dict/list
$ python3 -m timeit -n 1000000 -r 5 -v 'dict()'
raw times: 1.25 1.2 1.2 1.2 1.2
1000000 loops, best of 5: 1.2 usec per loop
$ python3 -m timeit -n 1000000 -r 5 -v '{}'
raw times: 0.375 0.368 0.375 0.375 0.372
1000000 loops, best of 5: 0.368 usec per loop
$ python3 -m timeit -n 1000000 -r 5 -v 'list()'
raw times: 1.28 1.29 1.28 1.29 1.28
1000000 loops, best of 5: 1.28 usec per loop
$ python3 -m timeit -n 1000000 -r 5 -v '[]'
raw times: 0.248 0.248 0.247 0.248 0.247
1000000 loops, best of 5: 0.247 usec per loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment