Looking at the NumPy C source file, this is the comment:
size : int
Number of elements in the array.
itemsize : int
The memory use of each array element in bytes.
nbytes : int
The total number of bytes required to store the array data,
i.e., ``itemsize * size``.
So in NumPy:
>>> x = np.zeros((3, 5, 2), dtype=np.float64)
>>> x.itemsize
8
So .nbytes is a shortcut for:
>>> np.prod(x.shape)*x.itemsize
240
>>> x.nbytes
240
So, to get a base size of a NumPy array without creating an instance of it, you can do this (assuming a 3x5x2 array of doubles for example):
>>> np.float64(1).itemsize * np.prod([3,5,2])
240
However, important note from the NumPy help file:
| nbytes
| Total bytes consumed by the elements of the array.
|
| Notes
| -----
| Does not include memory consumed by non-element attributes of the
| array object.