I want to get the size in bytes of numerical types, in particular those defined by numpy. This is achieved by this helper function,
def sizeof(dtype):
a = np.zeros(1, dtype=dtype)
return int(a.nbytes)
but I was wondering if there would be a built-in, less awkward way of doing it. sys.getsizeof is of no help in this case — it returns 400 bytes for all of numpy's numeric types I have tested.