title: Padding large numpy arrays
body: <p>Another numpy array handling question:
  I have an approx. 2000³ entries numpy array with fixed size (that I know), containing integers. I want to pad the array with another integer, so that it's surrounded in all dimensions. This integer is fixed for the whole padding process.</p>
  
  <pre><code>example (2D)
  1-----&gt;000
         010
         000
  </code></pre>
  
  <p>I have two ideas, leading to that result:</p>
  
  <ol>
  <li><p>Creating a larger numpy array, containing the padded values and "slicing" the old area in the padded:</p>
  
  <pre><code>padded=np.zeros((z+2,x+2,y+2))
  padded[1:z+1,1:x+1,1:y+1]=olddata
  </code></pre></li>
  <li><p>Using np.insert or hstack,vstack,dstack to add the values:</p>
  
  <pre><code>padded=np.insert(data,0,0,axis=0)
  padded=np.insert(data,x+1,0,axis=0) etc.
  </code></pre></li>
  </ol>
  
  <p>The Problem is, that all these methods are not in-place and allocate a new array (1.) or copy the old one (2.). Is there a way to do the padding in-place? I know, that since numpy 1.7. there's the numpy.pad module. But that also seems to use some kind of allocation and overriding (like in my 1. way).</p>