NumPy array from ctypes data
Feb. 26, 2007
11:13 a.m.
How can I create a NumPy array which is backed by ctypes data? ie create a NumPy array from a ctypes one without any data copying? So that changing an element of the NumPy array will alter the underlying ctypes array. I have C structures that contain numerical data and would like to access that data through the NumPy array interface. I have tried the following: PyObject *make_dbl_array(double *data, int n) { npy_intp dim = n; return PyArray_SimpleNewFromData(1, &dim, NPY_DOUBLE, (void *)data); } But when called via ctypes (with restype set to ctypes.py_object) it gives a bus error. Andrew
6925
Age (days ago)
6925
Last active (days ago)
0 comments
1 participants
participants (1)
-
Andrew McMurry