If you're using pickle
just for storing large values in a dictionary, or a very large number of keys, you should consider using shelve
instead.
import shelve
s=shelve.open('shelve.bin')
s['a']='value'
This loads each key/value only as needed, keeping the rest on disk