Skip to content

Instantly share code, notes, and snippets.

@agalera
Created August 5, 2015 12:02
Show Gist options
  • Save agalera/430acd2f5b37ed4b9196 to your computer and use it in GitHub Desktop.
Save agalera/430acd2f5b37ed4b9196 to your computer and use it in GitHub Desktop.
Speed structures in python
%timeit [0, 1, 2, 3, 4, 5]
10000000 loops, best of 3: 113 ns per loop
%timeit (0, 1, 2, 3, 4, 5)
100000000 loops, best of 3: 17.4 ns per loop
%timeit {0:0, 1:1, 2:2, 3:3, 4:4, 5:5}
1000000 loops, best of 3: 410 ns per loop
lista = [0, 1, 2, 3, 4, 5]
tupla = (0, 1, 2, 3, 4, 5)
diccionario = {0:0, 1:1, 2:2, 3:3, 4:4, 5:5}
%timeit lista[0]
10000000 loops, best of 3: 35.9 ns per loop
%timeit tupla[0]
10000000 loops, best of 3: 47.8 ns per loop
%timeit diccionario[0]
10000000 loops, best of 3: 50.8 ns per loop
%timeit lista[5]
10000000 loops, best of 3: 36.2 ns per loop
%timeit tupla[5]
10000000 loops, best of 3: 50 ns per loop
%timeit diccionario[5]
10000000 loops, best of 3: 51.6 ns per loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment