On Sat, Aug 8, 2020 at 2:21 AM <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2020-08-07 at 17:55:45 +0200, > Marco Sulla <marco.sulla.pyt...@gmail.com> wrote: > > @Chris: note that "real" recursion in Python is not possible, since > > there's no support for tail recursion. Maybe something similar can be > > done using async functions. > > Python has real recursion. Whether or not there's tail recursion on the > inside is an implementation detail.
More specifically: Python has real recursion. Whether or not tail recursion is optimized away is an implementation detail. Tail call optimization (there's no reason to restrict it to recursion alone) is something a Python implementation could choose to do, but the trouble is that full optimization tends to destroy traceback information, so it's often not worth doing. And the cases where partial optimization is of value just aren't compelling enough for anyone to implement it into CPython, nor any other major implementation (to my knowledge). The biggest uses for TCO tend to be the situations where recursion is the wrong solution to the problem. But recursion? Recursion is definitely possible. ChrisA -- https://mail.python.org/mailman/listinfo/python-list