I am using a Python (via ctypes) wrapped C library to run a series of computation. At different stages of the running, I want to get data into Python, and spec
ctypes
np.ctypeslib.as_array is all you need here.
From an array:
c_arr = (c_float * 8)() np.ctypeslib.as_array(c_arr)
From a pointer
c_arr = (c_float * 8)() ptr = ctypes.pointer(c_arr[0]) np.ctypeslib.as_array(ptr, shape=(8,))