First page Back Continue Last page Overview Image

Memory Consumption

from sys import getsizeof as size

lst = [24, 12, 57]

size_of_list_object = size(lst) # only blue box

size_of_elements = len(lst) * size(lst[0]) # 24, 12, 57

total_list_size = size_of_list_object + size_of_elements

print("Size without the size of the elements: ", size_of_list_object)

print("Size of all the elements: ", size_of_elements)

print("Total size of list, including elements: ", total_list_size)

Size without the size of the elements: 88

Size of all the elements: 84

Total size of list, including elements: 172