def _address_as_buffer(address, nbyte, readonly=False):
if address is None:
raise ValueError("Cannot create buffer from NULL pointer")
# Note: This doesn't work as a buffer when using pypy
# return (ctypes.c_byte*nbyte).from_address(address)
# Note: This works as a buffer in regular python and pypy
# Note: int_asbuffer is undocumented; see here:
# https://mail.scipy.org/pipermail/numpy-discussion/2008-January/030938.html
return np.core.multiarray.int_asbuffer(
address, nbyte, readonly=readonly, check=False)
评论列表
文章目录