python - ( How ) does scipy.integrate.odeint accelerate function evaluation? -


typically pure python is ~50x slower native code (c, fortran) if consist of tight loop simple aritmetics. when use scipy.odeint described example in tutorial write functions integrate in pure python this:

def f(y, t):        si = y[0]        zi = y[1]        ri = y[2]        # model equations (see munz et al. 2009)        f0 = p - b*si*zi - d*si        f1 = b*si*zi + g*ri - a*si*zi        f2 = d*si + a*si*zi - g*ri        return [f0, f1, f2] 

this function has evaluated manytimes, expect make huge performace bottleneck, considering odeint integrator made in fortran/odpack

does use convert function f(y,t) python native code? (like f2py, scipy.weave, cython ...) far know, odeint not need c/c++ or fortran compiler, , not increase initialization time of python script, f2py , scipy.weave not used.

i'm asking question, because, maybe, idea use same approach scipy.integrate.odeint use acceleration of tight loops in own code. using odeint more convenient using f2py or scipy.weave.

no doesn't, odeint code calls python function without optimization.

it wraps function in ode_function (see here) in turn calls python function call_python_function. c function ode_function used odepack module.

if keen on , ode/pde integrator supporting python c code conversion/speedup, have @ pydelay (link). uses in fact weave.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -