5

我想维护一个大型字典,有没有什么省内存的方法

 3 years ago
source link: https://www.v2ex.com/t/778691
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  Python

我想维护一个大型字典,有没有什么省内存的方法

  Phishion · 10 分钟前 · 43 次点击

字典大概是下面这样的结构,我粗跑了一下,大概 100W 条数据,占用 400M 内存

{'dn0pFVBjQGwRYKCO2Ix45ibo6r9kW3Zedn0pFVBjQGwRYKCO2Ix45ibo6r9kW3Ze': 1, 'XuYRUn50f7j9zG2k8EZvoaWmeAdqTVrQXuYRUn50f7j9zG2k8EZvoaWmeAdqTVrQ': 2, 
....
't2n9wLoU53ql4hPMHi7pFaIEkCRxNuf0t2n9wLoU53ql4hPMHi7pFaIEkCRxNuf0',1000000}

有没有方法能大幅度减少内存的占用?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK