Python 使用ctypes在C中调整numpy数组的大小

Python 使用ctypes在C中调整numpy数组的大小,python,numpy,ctypes,Python,Numpy,Ctypes,我使用ctypes将numpyndarray传递给C函数: lib = np.ctypeslib.load_library('library', 'path/to/library.so') lib.function.argtypes = [ numpy.ctypeslib.ndpointer(ndim=1, dtype=numpy.float64, flags='C,A,W') ] lib.function.restype = None arr = numpy.zeros((10), dtyp

我使用ctypes将numpy
ndarray
传递给C函数:

lib = np.ctypeslib.load_library('library', 'path/to/library.so')
lib.function.argtypes = [ numpy.ctypeslib.ndpointer(ndim=1, dtype=numpy.float64, flags='C,A,W') ]
lib.function.restype = None

arr = numpy.zeros((10), dtype=numpy.float64)
lib.function(arr)
具有以下C函数:

void function(double *arr)
{
    arr = (double *) realloc(arr, 20 * sizeof(double));
}
但是,阵列仍保持原始大小。在使用
numpy.ctypeslib.ndpointer
时,是否有一种简单的方法允许numpy数组更改大小