[SciPy-User] help speeding up a Runge-Kuta algorithm (cython, f2py, ...) (Sturla Molden)

Sergio Rojas sergio_r@mail....
Sun Aug 5 13:33:43 CDT 2012

************************************************************ Here is an example code of how to use Cython as a Fortran killer: https://github.com/sturlamolden/memview_benchmarks/blob/master/memview.pyx In this case, the performance with -O2 was just 2.2% slower than "plain C" with pointer arithmetics. It is possible to write very fast array code with Cython, but you must do it right. For comparison, this is very slow: https://github.com/sturlamolden/memview_benchmarks/blob/master/cythonized_numpy_2b.pyx What this mean is this: For anything but trivial code, the NumPy syntax is just too slow and should be avoided! I breiefly looked at the Cython code posted in this thread, and it suffers form all these issues. Sturla ********************************************** Hello Sturla, I am wondering whether there is a problem with my phyton installation or something is missing in your "memview.pyx" file as the following compiling error arises: cythoning memview.pyx to memview.c Error compiling Cython file: ------------------------------------------------------------ ... cimport numpy as np cimport cython @cython.boundscheck(False) @cython.wraparound(False) cdef np.float64_t slice_func(np.float64_t[::1] Xi, ^ ------------------------------------------------------------ memview.pyx:7:42: Expected an identifier or literal Sergio PD. Compilation works fine in the other files (cythonized_numpy_2b.pyx cythonized_numpy_4.pyx pointer_arith.pyx cythonized_numpy_2.pyx cythonized_numpy.pyx cythonized_numpy_3.pyx). Taking out that module in the "runme.py" file the output is: >$ python runme.py numpy_only: 3.13 sec cythonized_numpy: 2.38 sec cythonized_numpy_2: 3.8 sec cythonized_numpy_2b: 3.27 sec cythonized_numpy_3: 1.52 sec cythonized_numpy_4: 1.19 sec pointer_arith: 1.19 sec
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20120805/29c7882d/attachment.html 

More information about the SciPy-User mailing list