Can I force a numpy ndarray to take ownership of its memory?
问题 I have a C function that mallocs() and populates a 2D array of floats. It "returns" that address and the size of the array. The signature is int get_array_c(float** addr, int* nrows, int* ncols); I want to call it from Python, so I use ctypes. import ctypes mylib = ctypes.cdll.LoadLibrary('mylib.so') get_array_c = mylib.get_array_c I never figured out how to specify argument types with ctypes. I tend to just write a python wrapper for each C function I'm using, and make sure I get the types