Here is my example:
import numpy as np
test = [np.random.choice(range(1, 1000), 1000000) for el in range(1,1000)]
this object takes in memory:
print(sys.getsizeof(test)/1024/1024/1024)
8.404254913330078e-06
something like 8 KB
When I write it to disk
import pickle
file_path = './test.pickle'
with open(file_path, 'wb') as f:
pickle.dump(test, f)
it take almost 8GB from ls -l
command
Could somebody clarify why it take so little space in memory and some much on disk? I am guessing in memory numbers are not accurate.