I have a list of numpy.ndarrays (with different length) in python and need to have very fast access to those in python. I think an array of pointers would do the trick. I tried:
float_type_t* list_of_arrays[no_of_arrays]
for data_array in python_list_of_arrays:
list_of_arrays[0] = data_array
But cython complains:
no_of_arrays < Not allowed in a constant expression
I have tried several ways to constify this variable:
cdef extern from *:
ctypedef int const_int "const int"
(there have been more creative attempts) – however it unfortunatley doesn’t work.
Please help.
Why don’t you use a numpy object array instead of a list of arrays?
I think the problem you’re having is because you are declaring
list_of_arraysin the stack, and its size must be known at compile-time. You can try some dynamic allocation, like this:(This assumes
data_arrayis a numpy array.)But this is still guessing a bit what you want to do.