Note that nbytes
doesn't provide the correct value. For instance:
>>> n = 1000
>>> x = np.arange(n)
>>> bx = np.broadcast_to(x, (int(1e15), n))
>>> bx.nbytes
8e18
....which probably requires more RAM than exists on Earth.
EDIT: More specifically, is there a way to obtain the size of the buffer that bx
refers to? Something along the lines of:
>>> x.nbytes
8000
>>> bx.underlying_buffer_size()
8000