背景:我正在构build一个代表一个字典,使用最小的构buildalgorithm。 input列表是4.3M utf-8string,按字典顺序sorting。 生成的图是非循环的,最大深度为638个节点。 我的脚本的第一行通过sys.setrecursionlimit()将recursion限制设置为1100。 问题是:我希望能够将我的trie序列化到磁盘,所以我可以将它加载到内存中,而无需从头开始重build(大约22分钟)。 我已经尝试pickle.dump()和cPickle.dump() ,与文本和二进制协议。 每一次,我得到一个堆栈跟踪,如下所示: File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 649, in save_dict self._batch_setitems(obj.iteritems()) File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 663, in _batch_setitems save(v) File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 286, in save f(self, obj) # Call unbound method with explicit self File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 725, in save_inst save(stuff) File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 286, in save f(self, obj) # Call […]