title: Is convolution slower in Numpy than in Matlab?
body: <p>Convolution in Matlab appears to be twice as fast as convolution in Numpy. </p>
  
  <p>Python code (takes 19 seconds on my machine):</p>
  
  <pre><code>import numpy as np
  from scipy import ndimage
  import time
  
  img = np.ones((512,512,512))
  kernel = np.ones((5,5,5))/125
  
  start_time = time.time()
  ndimage.convolve(img,kernel,mode='constant')
  print "Numpy execution took ", (time.time() - start_time), "seconds"
  </code></pre>
  
  <p>Matlab code (takes 8.7 seconds on my machine):</p>
  
  <pre><code>img = ones(512,512,512);
  kernel = ones(5,5,5) / 125;
  tic
  convn(img, kernel, 'same');
  toc
  </code></pre>
  
  <p>The two give identical results.</p>
  
  <p>Is there a way to improve Numpy to match or beat Matlab's performance here? </p>
  
  <p>Interestingly, this factor or ~2 difference in runtimes is consistent at many input sizes.</p>