title: Cheapest way to get a numpy array into C-contiguous order?
body: <p>The following produces a C-contiguous numpy array:</p>
  
  <pre><code>import numpy
  
  a = numpy.ones((1024,1024,5))
  </code></pre>
  
  <p>Now if I slice it, the result may not longer be the same. For example:</p>
  
  <pre><code>bn = a[:, :, n]
  </code></pre>
  
  <p>with <code>n</code> from 0 to 4.
  My problem is that I need <code>bn</code> to be C-contiguous, and I need to do this for many instances of a. I just need each <code>bn</code> once, and want to avoid doing</p>
  
  <pre><code>bn  = bn.copy(order='C')
  </code></pre>
  
  <p>I also don't want to rewrite my code such that</p>
  
  <pre><code>a = numpy.ones((5,1024,1024))
  </code></pre>
  
  <p>Is there a faster, cheaper way to get <code>bn</code> than doing the copy?</p>
  
  <p>Background:</p>
  
  <p>I want to hash each slice of every <code>a</code>, using</p>
  
  <pre><code>import hashlib
  
  hashlib.sha1(a[:, :, n]).hexdigest()
  </code></pre>
  
  <p>Unfortunately, this will throw a <code>ValueError</code>, complaining about the order. So if there is another fast way to get the hash I want, I'd also use it.</p>