I've been working on a project that involves loading a relatively large dictionary into memory from a file. The dictionary has just under 2 million entries, each entry (key and value combined) is under 20 bytes. The size of the file on disk is 38 MB.
My problem is that when I try to load the dictionary, my program immediately expands to over 2.5 gigabytes of memory used.
Here is the code I use to read the dictionary in from disk:
f = open('someFile.txt', 'r')
rT = eval(f.read())
f.close()