我有一个包含 RAM 的大型字典对象dict_tmp
(40GB
系统总共有64GB
),它具有字符串键和浮点值。我使用d = shelve.open(fname, protocol=2)
andd['dict_tmp'] = dict_tmp
来保存字典,这会产生 foll 错误:
Traceback (most recent call last):
File "file.py", line 160, in <module>
d['dict_tmp'] = dict_tmp
File "/usr/lib/python2.7/shelve.py", line 133, in __setitem__
self.dict[key] = f.getvalue()
File "/usr/lib/python2.7/bsddb/__init__.py", line 279, in __setitem__
_DeadlockWrap(wrapF) # self.db[key] = value
File "/usr/lib/python2.7/bsddb/dbutils.py", line 68, in DeadlockWrap
return function(*_args, **_kwargs)
File "/usr/lib/python2.7/bsddb/__init__.py", line 278, in wrapF
self.db[key] = value
TypeError: Data values must be of type string or None.
我相信搁置模块适用于一般的python对象,但我认为这个问题可能与anydbm有关。任何帮助将非常感激!