[SciPy-dev] ctypes callbacks, changing signature

Gabriel Gellner ggellner@uoguelph...
Sat Mar 1 14:20:55 CST 2008


I am wrapping some ode solvers using ctypes. And I have run into, what I
imagine is, a common problem.

The expected C callback is of the form

void func(int n, double t, double* y, double* yprime);

which I can wrap fine using ctypes. But I would like to be able to use a
python (or f2py generated) function of the normal form

def func(t, y):
    # some callculations
    return yprime

# instead of
def func(n, t, y, prime):
    return None

My question is what do people usually do in this case? Any tips suggestions,
examples.

Thanks a bunch.

Gabriel


More information about the Scipy-dev mailing list