Код: Выделить всё
from pympler import asizeof
from random import randint, choice
from string import printable
from heapq import heappush
ascii = printable[:-5]
pq = []
for _ in range(10_000_000):
heappush(pq, (randint(0, 31), randint(0, 31), randint(0, 31), ''.join(choice(ascii) for _ in range(16))))
print(asizeof.asizeof(pq))
Вот что показывает «top»:

/usr/bin/time -v дает:
Код: Выделить всё
Maximum resident set size (kbytes): 2858616
Подробнее здесь: https://stackoverflow.com/questions/792 ... inaccurate
Мобильная версия