Python Stack Frames and Tail-Call Optimization

Avoiding stack overflow in Python using tail-recursion

Reza Bagheri
Towards Data Science
24 min readApr 24, 2020

--

Recursion in computer science is a method of problem-solving in which a function calls itself from within its own code. This method is very useful and can be applied to many types of problems, however, it has a limitation. Functions use the stack to keep their local variables, and the stack has…

--

--