I\'m writting a Cython wrapper to a C function. I have a pxd file with the following signature:
double contr_hrr(int lena, double xa, double ya, double za, doubl
cimport array
:
from cpython cimport array
Create an array object from your list. array class constructor will do all the heavy lifting allocating memory and iterating over your list (could be any iterable actually).
cdef array.array anorms2_arr = array.array('d', anorms2)
Pass its data to your function:
return contr_hrr(.., anorms2_arr.data.as_doubles)
array
is a standard Python module. Cython adds some special support on top, like buffer interface and direct access to the underlying memory block via arr.data.as_xxx
. Unfortunately, this support is only documented here.
You can also find some details about array usage in this recent thread.