Python dictionary loaded from disk takes too much space in memory

回眸只為那壹抹淺笑 提交于 2019-12-05 13:45:47

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

Fernando Retimo

Use SQL to store all the data into a database and use efficient queries to reach it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!