Python memory usage of numpy arrays

The Solution to Python memory usage of numpy arrays is


You can use array.nbytes for numpy arrays, for example:

>>> import numpy as np
>>> from sys import getsizeof
>>> a = [0] * 1024
>>> b = np.array(a)
>>> getsizeof(a)
8264
>>> b.nbytes
8192

~ Answered on 2012-08-02 19:24:14


Most Viewed Questions: