Why no tailcall-optimization?

sturlamolden sturlamolden at yahoo.no
Tue Sep 23 09:41:33 EDT 2008


On Sep 23, 3:13 am, process <circularf... at gmail.com> wrote:

> Why doesn't Python optimize tailcalls? Are there plans for it?

Because Python is a dynamic language. While a function is executing,
its name may be bound to another object. It may happen as a side
effect of what the function is doing, or even from another thread. The
compiler has no way of knowing that.

Recursion can always be expressed as iteration, possibly with a Python
list as stack.




More information about the Python-list mailing list