What actually causes a Stack Overflow error? [duplicate]

This question already has answers here: What is a StackOverflowError? (15 answers) Closed 6 years ago. I’ve looked everywhere and can’t find a solid answer. According to the documentation, Java throws a java.lang.StackOverflowError error under the following circumstance: Thrown when a stack overflow occurs because an application recurses too deeply. But this raises two questions: … Read more

Does Python optimize tail recursion?

I have the following piece of code which fails with the following error: RuntimeError: maximum recursion depth exceeded I attempted to rewrite this to allow for tail recursion optimization (TCO). I believe that this code should have been successful if a TCO had taken place. def trisum(n, csum): if n == 0: return csum else: … Read more