[SciPy-User] Cython vs Vectorized Numpy vs MATLAB

Jaidev Deshpande deshpande.jaidev@gmail....
Tue Nov 15 18:15:32 CST 2011


Hi,

I have two questions.

1. Why does the 'spline.m' function in MATLAB perform much faster than the
same interpolation in NumPy?
(In MATLAB the first function call takes time but the subsequent calls are
much faster.)

2. I wrote a cubic spline interpolation algorithm with NumPy and I
vectorized it. Is it surprising that the Cython compiled version of the
same function is no faster? I guess that shouldn't happen, as parts of the
code would be compiled into C. Although, please note that I used Cython on
the vectorized code *as it is*, without adding static types. I know, stupid
thing to do, but shouldn't it have given me *some *speed-up?

In my problem, for the same data

MATLAB takes .............................................................
 0.038 seconds
Vectorized NumPy takes.................................................
 1.0342 second
The above, Cythonized ...................................................
 0.997 seconds
Functions in the scipy.interpolate package take.................. well
above 1 second
(I've tried out almost everything scipy has to offer)

Since MATLAB is the fastest, I am trying to get Python to be atleast as
fast if not faster. Is that even possible? How?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20111116/d9f75a6a/attachment.html 


More information about the SciPy-User mailing list