title: Improving Numpy Performance
body: <p>I'd like to improve the performance of convolution using python, and was hoping for some insight on how to best go about improving performance. </p>
  
  <p>I am currently using scipy to perform the convolution, using code somewhat like the snippet below:</p>
  
  <pre><code>import numpy
  import scipy
  import scipy.signal
  import timeit
  
  a=numpy.array ( [ range(1000000) ] )
  a.reshape(1000,1000)
  filt=numpy.array( [ [ 1, 1, 1 ], [1, -8, 1], [1,1,1] ] )
  
  def convolve():
    global a, filt
    scipy.signal.convolve2d ( a, filt, mode="same" )
  
  t=timeit.Timer("convolve()", "from __main__ import convolve")
  print "%.2f sec/pass" % (10 * t.timeit(number=10)/100)
  </code></pre>
  
  <p>I am processing image data, using grayscale (integer values between 0 and 255), and I currently get about a quarter of a second per convolution. My thinking was to do one of the following:</p>
  
  <p>Use corepy, preferably with some optimizations
    Recompile numpy with icc &amp; ikml.
    Use python-cuda.</p>
  
  <p>I was wondering if anyone had any experience with any of these approaches ( what sort of gain would be typical, and if it is worth the time ), or if anyone is aware of a better library to perform convolution with Numpy.</p>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT:</strong> </p>
  
  <p>Speed up of about 10x by re-writing python loop in C over using Numpy. </p>