I wrote a C
application which uses some python
code, wrapped in cython
, to simplify some stuffs.
What I want to do is to return an array from a python
function, callable in C
.
main.c
PyImport_AppendInittab("wrapper", PyInit_libwrapper);
Py_Initialize();
PyObject *module = PyImport_ImportModule("wrapper");
char *names[] = get_names();
Py_Finalize();
wrapper.pyx
cdef public void get_names():
names = []
names.append('ABCD')
names.append('1234')
names.append('abcd')
return names
return names_size
Is it possible to return an array, of chars*
in that case?
To handle the array in C
I also need to have its size, but I can't pass an int size
by reference.
What's the best way to handle this?