You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
This is unfortunately a well known issue for copy, pickle and json when dealing with nested/recursive data structures. With this:
>>> from pygtrie import Trie
>>> from array import array
>>> t=Trie()
>>> for x in range(100):
... y = array('h', range(x, 1000)).tostring()
... t.update([(y,x,)])
...
>>> t2=t.copy()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
[...]
File "/home/pombreda/w421/scancode-toolkit-ref/local/lib/python2.7/site-packages/pygtrie.py", line 81, in iterate
for step, node in sorted(self.children.iteritems()):
RuntimeError: maximum recursion depth exceeded while calling a Python object
There are two ways out IMHO:
a custom de/serialization function that flattens the trie (eventually slow)
a different non-nested data structure for the Trie such as an array/list-based structure (e.g. double array Trie)
The text was updated successfully, but these errors were encountered:
To avoid reaching Python’s maximum recursion limit, convert
_Node.iterate method to be iterative with stack stored on heap
instead.
Sadly, the same cannot be done with _Node.traverse. An alternative
interface for traversing could be devised; perhaps in another commit.
Reported-by: Philippe Ombredanne <pombredanne@gmail.com> # #8
This is unfortunately a well known issue for copy, pickle and json when dealing with nested/recursive data structures. With this:
There are two ways out IMHO:
The text was updated successfully, but these errors were encountered: