pickle: maximum recursion depth exceeded
Simon Burton
simonb at webone.com.au
Mon Nov 3 20:34:40 EST 2003
Here is a simple example that breaks pickle.
(With N=256 all is well.)
This probably should go in the docs for pickle -
that highly interlinked data cannot be pickled.
I know that in the past we have been told not to
do this, because of GC issues, so I understand
if it's considered too pathalogical for now.
Simon.
#!/usr/bin/env python
#import cPickle as pickle
import pickle
import os
#sys.setrecursionlimit(4000)
N = 512
print "building..."
nest = [ [] for i in range(N) ]
for i in range(N):
for j in range(N):
nest[i].append( nest[j] )
print "dumping..."
file = open("nest.pkl","wb")
try:
pickle.dump( nest, file )
except RuntimeError, e:
print e
More information about the Python-list
mailing list