PyDAS
PyDAS copied to clipboard
Switch from Cython to f2py
I notice you have a bunch of work on an f2py branch, that uses numpy's f2py instead of Cython, and was wondering what the status is? I note the last commit message 07ed119564d22ddcf92dd6744e2042c9247e2605 mentions a possible speed penalty for cythonized residual functions?
If I remember right, the problem was that DASSL makes many calls to the residual function per time step in order to determine the appropriate step size. The change from Cython to f2py caused this to become a slow Python call instead of a faster Cython call. Even if the residual function is Cythonized, the f2py version still needs to pass through the Python layer to get from Fortran to the Cythonized residual, which the Cython version avoids. This might not be an issue if the overhead of the Python call is small compared to the time spent evaluating the residual itself, but that was not the case for the simple test case I was using at the time. Presumably it would be more true in RMG-Py, but I don't think I ever got that far.
OK, so not worth pursuing (unless someone really wants to avoid installing Cython). Good to know. Thanks.
I'll also note in this comment thread that if anyone does play around with this, be sure to clean out your python site_packages folder during and after your playing - the two different versions leave incompatible things lying around that could cause you a world of confusion.