I always thought numpy array is more compact and takes less memory size compare to list, however, for a 3-D float64 np array,
print (sys.getsizeof(result2)/1024./1024./1024.)
print (sys.getsizeof(result2.astype('float16'))/1024./1024./1024.)
print (sys.getsizeof(list(result2))/1024./1024./1024.)
print (sys.getsizeof(result2.tolist())/1024./1024./1024.)
The output is,
0.6521792411804199
0.16304489970207214
0.00033977627754211426
0.0003019943833351135
The list took much smaller memory. Is it validate to use sys.getsizeof
for list? If it is, can I do anything to improve np array memory use?
######################
Using pympler @J_H, (it seems pympler can't deal with arraies in a list, like list(a 3-D array ). )
print (result2.nbytes/1024./1024./1024.)
print (asizeof.asizeof(result2)/1024./1024./1024.)
print (result2.astype('float16').nbytes/1024./1024./1024.)
print (asizeof.asizeof(list(result2))/1024./1024./1024.)
print (asizeof.asizeof(result2.tolist())/1024./1024./1024.)
0.6521791219711304
0.6521792411804199
0.1630447804927826
0.004566863179206848
4.078836984932423
Thank you all!