With the new Cython 3.0+ API, the usage of ndarray.data
within Cython code is deprecated.
My question is how does one obtain a pointer to the underlying ndarray data then that is held by a memoryview? What is the proper syntax or methodology that abides by the NPY_1_7
C-API and Cython's new 3.0+ API?
My code used to look something like this:
arr = np.zeros((10,))
# arr_data is a pointer to the underlying data
cdef double* arr_data = <double*>arr.data
# I want a pointer because it can be passed efficiently to other functions
do_something_to_arr_data_in_cythonorcpp(arr_data)
cdef do_something_to_arr_data_in_cythonorcpp(double* arr_data):
for idx in range(10):
arr_data[idx] += idx