On 7/16/2015 3:45 PM, Marko Rauhamaa wrote:

Nobody seemed to notice that I just posted a fairly typical tail call
function:

Because non-recursive tail calls are completely normal. Example:
    return len(self.children)

Even tail operations like
    return a + b
are tail calls if rewritten as
    return a.__add__(b)
(usually but not always equivalent) or rewritten as
    return operator.add(a, b)
(always equivalent) or compiled by an implementation as an equivalent internal function call.

It happens to be that CPython implements calls to symbol operator functions by putting the bodies of such functions into a C switch inside a while loop. It this compiles operator symbols into bytecodes that cause a jump to the corresponding code.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to