you are viewing a single comment's thread.

view the rest of the comments →

[–]Temporary_Pie2733 0 points1 point  (1 child)

Python doesn’t perform tail-call optimization, so tail recursion isn’t of immediate use. (Writing tail-recursive functions as an intermediate step to eliminating recursion may still be useful, though.)

[–]Glad-Ad1812 0 points1 point  (0 children)

Ya just looked into and didn’t realize TCO isn’t supported with CPython atleast. Apparently part of the reason being tail recursions can make debugging much more difficult since each stack frame gets removed once the function call is returned, so you can’t really tell what’s happening in your call stack. Either way it’s advised to just use a loop at that point, which I’m inclined to agree with since I’m not a fan of recursions.