Possibly Pythonic Tail Call Optimization (TCO/TRE)

Marko Rauhamaa marko at pacujo.net
Tue Jul 14 07:57:27 CEST 2015


Ian Kelly <ian.g.kelly at gmail.com>:

> On Mon, Jul 13, 2015 at 11:25 PM, Chris Angelico <rosuav at gmail.com> wrote:
>> (Also, side point: Python can't actually optimize the above function,
>> because it actually means "call quicksort, then discard its return
>> value and return None". A true tail call has to return the result of
>> the recursive call, and Python lacks a way to say "this function will
>> always return None". But that's trivial.)
>
> Another point in favor of an explicit tail-call keyword. Then one
> couldn't make that mistake.

How about "return"?


Marko


More information about the Python-list mailing list