I am implementing A* search using a priority queue. Each item in my priority queue has three ints and a string of length up to 16. The size of the graph I can run my search on is currently limited by the amount of memory my priority queue takes. Each int takes 32 bytes and the string takes 64 bytes in Python.
The minimum possible space would be 8 bytes per int (they are never more than 64 bits) + 16 bytes making 40 bytes overall.
Is it possible to reduce the space to close to 40 bytes per tuple?
Here is a MWE that makes some fake random data.
from pympler import asizeof
from random import randint, choice
from string import printable
from heapq import heappush
ascii = printable[:-5]
pq = []
for _ in range(10000):
heappush(pq, (randint(0, 31), randint(0, 31), randint(0, 31), ''.join(choice(ascii)
print(asizeof.asizeof(pq))
This gives 1446200 bytes. (This is a little less than (32*3 + 64) * 10,000 confusingly.
Is it possible to get it down to close to 400,000 bytes?