[SciPy-User] Cython vs Vectorized Numpy vs MATLAB

Hjalmar Turesson hturesson@gmail....
Tue Nov 15 19:46:05 CST 2011


Hi,

splmake and spleval (in scipy.interpolate) appear to run as fast as spline in
matlab. They are approximately 30 times faster than cspline1d and
cspline1d_eval.

Best,
Hjalmar


On Tue, Nov 15, 2011 at 7:15 PM, Jaidev Deshpande <
deshpande.jaidev@gmail.com> wrote:

> 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
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20111115/d15712ea/attachment.html 


More information about the SciPy-User mailing list