2
数组我已经做了这个功能,它使用ctypes的创建具有指向指定地址的缓存协议的对象:构建从内存地址
import numpy as np
def np_buffer_from_address(shape, dtype, address):
import ctypes
return np.ndarray(shape, dtype = dtype, buffer = ctypes.c_void_p.from_address(address))
但我想知道如果我能做到这一点不使用ctypes。如果你可以用numpy的直接做到这一点
“地址”的来源是什么?在链接中,我显示你可以使用另一个数组的'.data'属性。 https://stackoverflow.com/a/39377877/901925 – hpaulj
'numpy.ctypes'可能有帮助; https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.ndarray.ctypes.html – hpaulj