I've been getting RuntimeError: maximum recursion depth exceeded
when trying to pickle a highly-recursive tree object. Much like this asker here.
He solved his problem by setting the recursion limit higher with sys.setrecursionlimit
. But I don't want to do that: I think that's more of a workaround than a solution. Because I want to be able to pickle my trees even if they have 10,000 nodes in them. (It currently fails at around 200.)
(Also, every platform's true recursion limit is different, and I would really like to avoid opening this can of worms.)
Is there any way to solve this at the fundamental level? If only the pickle module would pickle using a loop instead of recursion, I wouldn't have had this problem. Maybe someone has an idea how I can cause something like this to happen, without rewriting the pickle module?
Any other idea how I can solve this problem will be appreciated.