About 100,000 results
Open links in new tab
  1. Does Python optimize tail recursion? - Stack Overflow

    Nov 28, 2012 · 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 …

  2. algorithm - What is tail recursion? - Stack Overflow

    Aug 29, 2008 · Tail recursion optimization is to remove call stack for the tail recursion call, and instead do a jump, like in a while loop. But if you do use the return value of a recursive call …

  3. Python Tail Recursion "Hack" using While Loop - Stack Overflow

    Sep 7, 2020 · The Python developers have decided that they prefer the simplicity and debuggability of normal recursion over performance benefits of tail call optimization, even …

  4. python - Tail Recursion Fibonacci - Stack Overflow

    Mar 1, 2014 · Reading it again it was obvious the correct solution was a tail-recursion. But then again, it still doesn't make much sense, as Python doesn't even support tail-recursion elimination.

  5. What's the big deal with tail-call optimization and why does Python …

    Jan 2, 2024 · If you intensely want to use recursion for things that might alternatively be expressed as loops, then "tail call optimization" is really a must. However, Guido, Python's …

  6. algorithm - What is tail call optimization? - Stack Overflow

    Mar 21, 2012 · 987 Tail-call optimization is where you are able to avoid allocating a new stack frame for a function because the calling function will simply return the value that it gets from …

  7. The difference between head & tail recursion - Stack Overflow

    Jan 29, 2014 · In head recursion, the recursive call, when it happens, comes before other processing in the function (think of it happening at the top, or head, of the function). In tail …

  8. Why is Python recursion so expensive and what can we do about it?

    Jun 15, 2021 · ² Exceptions to this rule of thumb are certain functional languages that guarantee tail-recursion elimination - such as Haskell - where that rule can be relaxed in case of …

  9. Why is tail recursion optimization faster than normal recursion in …

    May 12, 2016 · 17 While I understand that tail recursion optimization is non-Pythonic, I came up with a quick hack to a question on here that was deleted as soon as a I was ready to post. With …

  10. Using python to implement the tail recursion function

    Mar 31, 2022 · Note that python does not have tail call optimization, so forcing code to be tail recursive is generally a waste. Do you really need this restriction (e.g. for an exercise) or do you …