@Chris: you're very right, but, I repeat, you can't have a real TCO (asyncio apart):
(venv_3_10) marco@buzz:~$ python Python 3.10.0a0 (heads/master-dirty:ba18c0b13b, Aug 14 2020, 17:52:45) [GCC 10.1.1 20200718] on linux Type "help", "copyright", "credits" or "license" for more information. >>> def factorial(n): ... if n in (1, 2): ... return n ... return n * factorial(n-1) ... >>> factorial(6) 720 >>> factorial(1000) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 4, in factorial File "<stdin>", line 4, in factorial File "<stdin>", line 4, in factorial [Previous line repeated 995 more times] File "<stdin>", line 2, in factorial RecursionError: maximum recursion depth exceeded in comparison Anyway, tail call is introduced in Python, but only for asyncio: "If a Future.set_exception() is called but the Future object is never awaited on, the exception would never be propagated to the user code. Enable the debug mode to get the traceback where the task was created" https://docs.python.org/3.10/library/asyncio-dev.html#detect-never-retrieved-exceptions So, in theory, nothing prevents Python from having a Tail Call Optimization... because it already has it! The only problem is that it's applied to asyncio only. IMHO it's not a big problem to support generic TCO, and disable it for debugging purposes enabling the Python dev mode. -- https://mail.python.org/mailman/listinfo/python-list