title: Efficient Python array with 100 million zeros?
body: <p>What is an efficient way to initialize and access elements of a large array in Python?</p>
  
  <p>I want to create an array in Python with 100 million entries, unsigned 4-byte integers, initialized to zero. I want fast array access, preferably with contiguous memory.</p>
  
  <p>Strangely, <a href="http://en.wikipedia.org/wiki/NumPy" rel="noreferrer">NumPy</a> arrays seem to be performing very slow. Are there alternatives I can try?</p>
  
  <p>There is the <a href="http://docs.python.org/library/array.html" rel="noreferrer">array.array</a> module, but I don't see a method to efficiently allocate a block of 100 million entries.</p>
  
  <p>Responses to comments:</p>
  
  <ul>
  <li>I cannot use a sparse array. It will be too slow for this algorithm because the array becomes dense very quickly.</li>
  <li>I know Python is interpreted, but surely there is a way to do fast array operations?</li>
  <li>I did some profiling, and I get about 160K array accesses (looking up or updating an element by index) per second with NumPy. This seems very slow.</li>
  </ul>