I want to wrap this simple function:
double foo(int a, int* b)
{
double div = ((double) a) / ((double) *b);
*b = a + (*b);
return div;
}
what i'm trying to do is this:
cdef pyfoo(int c, int d):
res = foo(c, &d);
return (res, d)
I want to return a list of values, but using cdef it does not work it gives me the erroe: AttributeError no attribute pyfoo If instead of cdef i use def or cpdef it works.
Is there some way in cython to do this using cdef?
cdef functions can't be accessed by Python code. That's why they're fast: calling functions from Python is always slow.
The solution is using cpdef instead, so that it's both accessible from Python and fast when called from C. Or, don't call it from Python code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With