I'd like to pass function pointers as in e.g. c. In python of course
function pointers are automatically passed. I can't find documentation
on this. I tried both c and python-like syntax and neither worked.
Below is my "c-syntax" (failed) attempt.
------------------------------------------------------------------------------------------------------------
cdef float Plus (float a, float b):
return a+b
############
# This block will not compile
cdef use_fun_ptr(float a, float b, float (*pt2Func) (float, float)):
cdef float result
result = pt2Func(a,b)
return result
############
def main():
cdef float use_fun_ptr(float, float, float (float, float))
# This line works
print "Using Plus directly, " + str(Plus(2,5))
#
print "Using use_fun_ptr, " + str( use_fun_ptr(2, 5, &Plus) )
------------------------------------------------------------------------------------------------------------
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev