Skip to content

Instantly share code, notes, and snippets.

@smarnach
Created February 28, 2012 22:32
Show Gist options
  • Select an option

  • Save smarnach/1935721 to your computer and use it in GitHub Desktop.

Select an option

Save smarnach/1935721 to your computer and use it in GitHub Desktop.
In [1]: a = array.array("i", range(100000))
In [2]: b = array.array("i", range(100000))
In [3]: %timeit for i, x in enumerate(a): b[i] = 2 * x
10 loops, best of 3: 20.6 ms per loop
In [4]: a = range(100000)
In [5]: b = range(100000)
In [6]: %timeit for i, x in enumerate(a): b[i] = 2 * x
100 loops, best of 3: 15.7 ms per loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment