It seems you can expose cb_func
and cb_info
doing something similar to this toy example:
import numpy as np
cimport numpy as np
ctypedef void (*f_type)(int, double*, double*)
ctypedef struct IntOptCP:
int a
double *b
double *c
f_type f
cdef class MyClass:
cdef IntOptCP _iocp
def exec_f(self):
self._iocp.f(self._iocp.a, self._iocp.b, self._iocp.c)
cdef void myfunc(int a, double *b, double *c):
cdef int i
for i in range(a):
b[i] += 1
c[i] += 1
def main():
cdef f_type f
cdef np.ndarray[np.float64_t, ndim=1] b, c
cdef int a
a = 100
b = np.zeros(a, dtype=np.float64)
c = np.zeros(a, dtype=np.float64)
test = MyClass()
test._iocp.a = a
test._iocp.b = &b[0]
test._iocp.c = &c[0]
test._iocp.f = myfunc
print 'before', a, b, c
test.exec_f()
print 'after', a, b, c