Hitting Maximum Recursion Depth Using Pickle / cPickle

From the docs:

Trying to pickle a highly recursive data structure may exceed the maximum recursion depth, a RuntimeError will be raised in this case. You can carefully raise this limit with sys.setrecursionlimit().

Although your trie implementation may be simple, it uses recursion and can lead to issues when converting to a persistent data structure.

My recommendation would be continue raising the recursion limit to see if there is an upper bound for the data you are working with and the trie implementation you are using.

Other then that, you can try changing your tree implementation to be “less recursive”, if possible, or write an additional implementation that has data persistence built-in (use pickles and shelves in your implementation). Hope that helps

Leave a Comment