Pikonovsky picker - recursion depth exceeded

I am trying to uncover an instance of a class of cellular machines, but I get this error:

RuntimeError: maximum recursion depth exceeded while calling a Python object 

My cellular automata consist of a list of cells (and many other things), where each cell has a pointer to its neighbors. This particular CA has 256 cells. Now I know that pickler should be able to recognize already pickled objects.

From the docs:
* The brine module keeps track of objects that it has already serialized, so that subsequent links to the same object will not be serialized again.

So I really don’t know why I exceeded the maximum recursion depth.

I think that perhaps pickler does the depth of the first etching, so that it first follows the pointers, exceeds the recursion stack and then raises an exception. I know that I can extend the recursion depth with sys.setrecursionlimit() , but I don't think this is a good or scalable solution.

First question : Does it have a pickled depth?
Second question : any idea how to prevent this exception?

+6
source share
1 answer

So, as @ExP said, pickler does depth-first etching, which causes an exception to be thrown in recursion. Anyway, I found a solution to this problem here bugs.python.org . This means that the pinton 3.1 pickler works even on recursive data, such as graphs.

There is also a slightly less elegant solution that requires much more time to sort recursive data, but it is simple (just a few lines of code). Link here .

It seems like the time to start is slowly moving towards python3. Hope someone finds this answer helpful.

+6
source

All Articles