[SciPy-User] why is my scipy slow?
josef.pktd at gmail.com
josef.pktd at gmail.com
Thu Jan 31 22:49:59 EST 2013
On Thu, Jan 31, 2013 at 10:39 PM, John <jmjatkins at gmail.com> wrote:
> Hello,
>
> I've been using scipy for a few weeks now and for the most part am thoughily
> enjoying it! However I have been porting code from matlab and have been
> surprissed by how much slower it is runnning under python. So much so that I
> suspect I must be doing something wrong. Below is an example. In matlab the
> doSomething() function takes 6.4ms. In python it taks 78ms, more than 10x
> slower. Does this seem right? Or am I missing something? I installed the
> Enthough distribution for Windows. Any advise much appreaciated!
>
> First in python:
>
> import time
> import scipy.signal
>
> def speedTest():
> rep = 1000
> tt = time.time()
> for i in range(rep):
> doSomething()
> print (time.time() - tt) / rep
>
> def doSomething():
> lp = scipy.signal.firwin(16, 0.5);
> data = scipy.rand(100000)
> data = scipy.signal.convolve(data, lp)
>
> if __name__ == '__main__':
> speedTest()
>
>
>
> Now in matlab:
>
> function matlabSpeedTest()
> rep = 1000;
> tStart=tic;
> for j=1:rep
> doSomething();
> end
> tElapsed=toc(tStart)/rep;
> str = sprintf('time %s', tElapsed);
> disp(str);
> end
>
> function data = doSomething()
> lp = fir1(16,0.5);
> data = rand(100000, 1, 'double');
> data = conv(lp, data);
> end
maybe you want fftconvolve, faster for long arrays
Josef
>
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
More information about the SciPy-User
mailing list