I have a C function in write.h:
int write(int fd, void* arr, int size);
I have written write.pxd file to define it in Cython:
cdef extern from "write.h":
int write(int fd, void* arr, int size)
Now, how do I write the write.pyx for its implementation. I tried this:
def write(int fd, void* buf, int size):
return write(fd, buf, size)
But it complains that:
Cannot convert Python object argument to type 'void *'
How should I define so that I can send a list from Python and C gets the starting address of that list. For example, I want to call:
my_list = [1, 2, 3]
write(fd, my_list, 3 * 4)
as sizeof(int)
is 4.