Greg Ewing writes:
It's also by no means certain that TCO would provide the kind of speed benefit that people imagine. A lot of the overhead of making a Python function call is concerned with packing up the arguments and unpacking them again, which you still need to do even if you're reusing the stack frame.
I thought that was a good part of the appeal of TCO, though, that the compiler can often arrange to do data manipulations in such a way that the stack frame (or even data-in-register) is just there, ready to go when control is transferred. Ie, the packing/unpacking that is purely related to function calling is avoided. Is this a difficulty in implementing for Python, or did I misunderstand the concept? Ie. that's my fuzzy recollection of a head-splitting conversation with a Schemer that started, "what does call-with-current-continuation *do*?" and part I of his lecture finished with "well, why don't we start with something a little easier like tail call optimization?" Incomprehension-is-my-middle-name-ly y'rs,