I have a bunch of cdef
functions in Cython, that are called by a def
function in a pyx
file, e.g.:
cdef inline void myfunc_c(...):
(...)
return
def wrapper(...):
myfunc_c(...)
return
This works well. But to simplify not having to have a python wrapper for each cdef
function, I was trying to index the cdef
functions by name, either by assigning them to a dictionary or something like:
def wrapper(operation):
if operation == 'my_func':
func = myfunc_c
func(...)
return
But this doesn't work. Cython complains that it doesn't know the type of myfunc_c
.
Is there any way to index or call the cpdef
functions by name (e.g. use a string)? I also tried things like locals()['myfunc_c']
, but that doesn't work either.