|
|
|
|
|
by Jtsummers
755 days ago
|
|
What amuses me is that he goes on to explain how you'd retain the existing Python behavior and still do a tail call optimization. You have to retain the late binding by not converting the call-return into a jump but instead to a special new call_return which still performs the lookup (to satisfy late binding) and can reuse the stack frame instead of generating a new one. This would work for every instance of call-return pairs except in try statements and similar (anything that that has whatever Python calls unwind-protect). Since, in those cases, the except/finally/else of a try is code that may be executed (or is always executed in the case of the finally) after the call but before the return. So it really does come down to a desire to prevent the use of deep call stacks (auto-recursion is just one case that would have been optimized here) rather than a true technical limitation. This could even have been brought in incrementally over the years and provided as an option. |
|