Recursion Limits and Tail Recursion
Let’s learn about the limitations of recursion in Python. Additionally, we’ll also look at the concept of tail recursion.
We'll cover the following...
Multiple function calls
Recursion is relatively inefficient compared to looping. This is because each step in a recursion results in a function call, whereas each step in a loop merely requires a “jump” to a different place in the code.
Calling a function involves considerably more work than a simple jump, and, in any system, it is going to take more time and use extra memory (memory is required to store the current state of the function – the values of its local variables – each time the function calls itself recursively).
Limit on recursive calls
However, Python has a rather more immediate problem. Recursive calls are ...
Access this course and 1400+ top-rated courses and projects.