On Sat, Apr 05, 2008 at 12:58:21PM -0400, [EMAIL PROTECTED] wrote: > > Could anyone give me a tip on how to convert a python function > > of the form > > > > def func(x): > > return some_operation(x) > > > > to a C function of the form > > > > cdef void cfunc(double x, double *y): > > y = some_operation(x) > > y[0] = some_operation(x) > Yeah, sorry that was a typo...
> > > > That is I want to be able to turn a python function into > > a C function with pass by reference return semantics. > > > > I looked at the cheesefinder example, and I am not sure how to adapt it, > > as I > > want to be able to have the user supply the python function, and I can't > > think > > of how to make a cdef callback function that knows what this function is, > > that > > is > > > > cdef void callback(souble x, double *y): > > y = func(x) > > > > I am not sure how to set func in this way, without rewriting the cdef each > > time. In python I would just use a higher order function . . . > > in general, you need an extra "void *" argument in the callback > function (which you would use to pass a python callable). > Well designed C libraries use this convention, but it > sounds like you don't have this. > Curses, I guess I will have to change the original code :-( Thanks for the help. Gabriel _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
