Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement tree printing to avoid maximum recursion depth error #718

Open
harryrichman opened this issue Oct 17, 2023 · 0 comments
Open

Implement tree printing to avoid maximum recursion depth error #718

harryrichman opened this issue Oct 17, 2023 · 0 comments

Comments

@harryrichman
Copy link

Printing a Tree object relies on the _asciiArt method that is implemented using pure recursion, which can result in a RecursionError for a sufficiently large tree. If the implementation is modified to use memoization, then this recursion error could be avoided.

Example:

t = Tree("(0);")
for i in range(1001):
    (t&str(i)).add_child(name=str(i + 1))
print(t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant