title: What is the preferred way to preallocate NumPy arrays?
body: <p>I am new to NumPy/SciPy. From the documentation, it seems more efficient to preallocate
  a single array rather than call append/insert/concatenate. </p>
  
  <p>For example, to add a column of 1's to an array, i think that this:</p>
  
  <pre><code>ar0 = np.linspace(10, 20, 16).reshape(4, 4)
  ar0[:,-1] = np.ones_like(ar0[:,0])
  </code></pre>
  
  <p>is preferred to this:</p>
  
  <pre><code>ar0 = np.linspace(10, 20, 12).reshape(4, 3)
  ar0 = np.insert(ar0, ar0.shape[1], np.ones_like(ar0[:,0]), axis=1)
  </code></pre>
  
  <p>my first question is whether this is correct (that the first is better), and my second question is, at the moment, I am just preallocating my arrays like this (which I noticed in several of the Cookbook examples on the SciPy Site):</p>
  
  <pre><code>np.zeros((8,5))
  </code></pre>
  
  <p>what is the 'NumPy-preferred' way to do this?</p>