https://nyu-cds.github.io/python-cython/
http://apprize.info/python/cython/index.html
http://cython.readthedocs.io/en/latest/src/userguide/extension_types.html
https://github.com/cython/cython/wiki/FAQ
https://media.readthedocs.org/pdf/cython/stable/cython.pdf
20170924 use callback sample to do a function table
cdef extern from "cheesefinder.h":
ctypedef void (*cheesefunc)(char *name, void *user_data)
ctypedef struct cheesetable:
pass
cdef cheesefunc g_table3
should have ‘cheesetable’ type , come from ‘extern from a prototpe file’
cdef extern from "cheesefinder.h":
ctypedef void (*cheesefunc)(char *name, void *user_data)
cdef int mycalclen(char *name, void *f):
global prefix # for example: "value-len:"
l = 0
if name:
l = len(name.decode('utf-8'))
print("inside mycalclen " + prefix + str(l))
return l
from cpython.string cimport PyString_AsString
cdef char ** to_cstring_array(list_str):
cdef char **ret = <char **>malloc(len(list_str) * sizeof(char *))
for i in xrange(len(list_str)):
ret[i] = PyString_AsString(list_str[i])
return ret
if missing ‘from cpython.string import PyString_AsString’, only got the wrong message
gap_if.pyx:31:34: Storing unsafe C derivative of temporary Python reference