numpy.dtype.itemsize — NumPy v2.6.dev0 Manual

attribute

dtype.itemsize

#

The element size of this data-type object.

For 18 of the 21 types this number is fixed by the data-type. For the flexible data-types, this number can be anything.

Examples

>>> importnumpyasnp>>> arr=np.array([[1,2],[3,4]])>>> arr.dtypedtype('int64')>>> arr.itemsize8>>> dt=np.dtype([('name',np.str_,16),('grades',np.float64,(2,))])>>> dt.itemsize80