*大型*带有持久性存储的python字典,用于快速查找 [英] *large* python dictionary with persistence storage for quick look-ups

查看:89
本文介绍了*大型*带有持久性存储的python字典,用于快速查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有4亿行唯一的键值信息,我希望这些信息可用于在脚本中进行快速查找.我想知道这样做的巧妙方法.我确实考虑了以下内容,但不确定是否有一种方法可以对字典进行磁盘映射,并且在字典创建过程中无需使用大量内存.

I have a 400 million lines of unique key-value info that I would like to be available for quick look ups in a script. I am wondering what would be a slick way of doing this. I did consider the following but not sure if there is a way to disk map the dictionary and without using a lot of memory except during dictionary creation.

  1. 腌制的字典对象:不确定这是否是解决我的问题的最佳方法
  2. NoSQL类型dbases:理想情况下,它希望对第三方东西的依赖性最小,并且键值只是数字.如果您仍然认为这是最佳选择,我也想听听.也许它将说服我.

请让我知道是否有任何不清楚的地方.

Please let me know if anything is not clear.

谢谢! -阿比

推荐答案

如果要保留大型词典,则基本上是在查看数据库.

If you want to persist a large dictionary, you are basically looking at a database.

Python内置了对 sqlite3 的支持,从而为您提供了一个简单的数据库解决方案,并提供了以下支持磁盘上的文件.

Python comes with built in support for sqlite3, which gives you an easy database solution backed by a file on disk.

这篇关于*大型*带有持久性存储的python字典,用于快速查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆