title: Numpy individual element access slower than for lists
body: <p>I just started using Numpy and noticed that iterating through each element in a Numpy array is ~4x slower than doing the same but with a list of lists. I know now that this defeats the purpose of Numpy and I should vectorize the function if possible. My question is though why is it 4x slower. That seems like quite a large amount.</p>
  
  <p>I ran the tests below using <code>%timeit</code></p>
  
  <pre><code>import numpy as np
  b = np.eye(1000)
  a = b.tolist()
  
  %timeit b[100][100] #1000000 loops, best of 3: 692 ns per loop
  %timeit a[100][100] #10000000 loops, best of 3: 70.7 ns per loop
  %timeit b[100,100] #1000000 loops, best of 3: 343 ns per loop
  %timeit b.item(100,100) #1000000 loops, best of 3: 297 ns per loop
  </code></pre>
  
  <p>I tried to use <code>dis.dis</code> to see what was going on under the hood but got:</p>
  
  <pre><code>TypeError: don't know how to disassemble method-wrapper objects
  </code></pre>
  
  <p>Then I tried to look at the Numpy source code but couldn't figure out which file corresponded to array element access. I'm curious what accounts for the extra overhead, and more importantly how to figure this out for myself in the future. It seems like python can't be easily compiled to C code so that I can see the difference. But is there a way to see what byte code is generated for each line, to get a sense of the differences?</p>