You need to convert the list into a (manually) allocated int*
yourself. For example,
from libc.stdlib cimport malloc, free # or "from stdlib..."
def somefunc_py(int type, dims, char *name, foo):
cdef int *dims_c = NULL, *foo_c = NULL
try:
dims_c = malloc(sizeof(int) * len(dims))
if dims_c == NULL:
raise MemoryError
for i, a in enumerate(dims):
dims_c[i] = a
foo_c = malloc(sizeof(int) * len(foo))
if foo_c == NULL:
raise MemoryError
for i, a in enumerate(foo):
foo_c[i] = a
somefunc(type, len(dims), dims_c, name, foo_c)
finally:
if dims_c != NULL:
free(dims_c)
if foo != NULL:
free(foo)
You could factor some of this out to a utility function if you're
going to use it a lot. I'm completely ignoring the fat that you may
want to do some encoding/decoding for your char*, and/or check the
dimensions for dims and foo for compatibility.
This is certainly something we would like to make more natural.
- Robert