[SciPy-User] help speeding up a Runge-Kuta algorithm (cython, f2py, ...)
Sat Aug 4 16:49:29 CDT 2012
Den 04.08.2012 21:35, skrev Jonathan Stickel:
> I am sure properly coded Cython is great, but I really struggled when I
> tried to use it.
I uses np.ndarray declarations and array expressions. Those will be
slow. To write fast and numpyonic Cython, use typed memoryviews instead,
and write out all loops. I.e. there is no support for array expressions
with these yet. And unfortunately there is a huge lack of documentation
on how to use typed memoryviews efficiently.
Here is an example code of how to use Cython as a Fortran killer:
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:
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.
More information about the SciPy-User