Skip to content Skip to sidebar Skip to footer

Constructing An Array From Memory Address

I have done this function that uses ctypes to create an object with a buffer protocol that points to a specified address: import numpy as np def np_buffer_from_address(shape, dtyp

Solution 1:

You can avoid ctypes by using just the standardized __array_interface__, here's an example how it works: Creating a NumPy array directly from __array_interface__ (in fact, numpy.ctypeslib.as_array does the same under the hood, setting typestr and data appropriately)


Post a Comment for "Constructing An Array From Memory Address"