Cython error: Cannot convert Python object to type 'int *' error, when passing an Integer array to a function
cython, pass-by-reference, python
Solution
The issue here is the function is `cpdef` - this means it can be called from both C and Python code, and means all arguments must be Python objects (otherwise how would one call it from Python?)
Declare it as `cdef` instead.
Problem
I am trying to pass an integer array to a function in Cython and I cannot understand why I get the error mentioned in the title. A sample code of what I am trying to do is the following: ``` cpdef foo(int *table): for i in range(10): table[i] = i cdef int *temp=<int *>malloc(10*sizeof(int)) foo(temp) for i in range(10): print temp[i] ``` I would appreciate any pointers as to how to pass the array correctly to the function. Thank you.