cdef extern from "stdlib.h": void * malloc(size_t) void free(void *) cdef extern from "mylib.h": char * c_myfun_s "myfun_s"(char *, char *) double c_myfun_d "myfun_d"(double, double) int c_myfun_i "myfun_i"(int, int ) int c_myfun_a "myfun_a"(int *, int ) def myfun_s(a, b): return c_myfun_s(a, b); def myfun_d(a, b): return c_myfun_d(a, b); def myfun_i(a, b): return c_myfun_i(a, b); def myfun_a(lst): cdef int * a a = malloc(len(lst)*sizeof(int)) for i, e in enumerate(lst): a[i] = e result = c_myfun_a(a, len(lst)); free(a) return result __all__ = ["myfun_s", "myfun_d", "myfun_i"]