Possibly Pythonic Tail Call Optimization (TCO/TRE)

Marko Rauhamaa marko at pacujo.net
Tue Jul 14 20:37:02 CEST 2015

Steven D'Aprano <steve at pearwood.info>:

> Tail call behaviour is not undefined in Python. There is a strong
> convention (followed by all implementations I know of) to follow the
> reference implementation's (CPython) behaviour, which is not to
> optimize tail calls. But even if an implementation chooses to not
> follow that, it's not *undefined behaviour*. It's just
> implementation-dependent behaviour.

But in Scheme, tail call elimination is mandatory and thus can be relied
on. Unless that promise is made, you can't write code that depends on


More information about the Python-list mailing list