title: Why is using a Cython list faster than using a Python list?
body: <p>Here's my Python code:</p>
  
  <pre><code>X = [[0] * 1000] * 100
  start = time()
  for x in xrange(100):
      for i in xrange(len(X)):
          for j in xrange(len(X[i])):
              X[i][j] += 1
  print  time() - start
  </code></pre>
  
  <p>My Cython code is the same:</p>
  
  <pre><code>X = [[0] * 1000] * 100
  start = time()
  for x in xrange(100):
      for i in xrange(len(X)):
          for j in xrange(len(X[i])):
              X[i][j] += 1
  print  time() - start
  </code></pre>
  
  <p>Output: </p>
  
  <ul>
  <li>Python cost: 2.86 sec</li>
  <li>Cython cost: 0.41 sec</li>
  </ul>
  
  <p><s>Any other <strong>faster way</strong> to do the same above in Python or Cython?</s> </p>
  
  <p><strong>Update: Any way to create an 2d array X with height indexing performance close to array int X[][] that in C/C++?</strong>  </p>
  
  <p>For now I am considering use Python C API to do the job.</p>
  
  <p>One more thing, a numpy array does the same thing but so much slower(70 sec) than list in both pure Python and Cython.</p>
  
  <p>Python:</p>
  
  <pre><code>X = np.zeros((100,1000),dtype=np.int32)
  start = time()
  for x in xrange(100):
      for i in xrange(len(X)):
          for j in xrange(len(X[i])):
              X[i][j]+=1
  </code></pre>
  
  <p>If doing a lot of access to numeric array, which approach is the best? </p>