Possibly Pythonic Tail Call Optimization (TCO/TRE)

Chris Angelico rosuav at gmail.com
Thu Jul 16 16:00:05 CEST 2015


On Thu, Jul 16, 2015 at 11:56 PM, Antoon Pardon
<antoon.pardon at rece.vub.ac.be> wrote:
> On 07/16/2015 01:45 PM, Chris Angelico wrote:
>> On Thu, Jul 16, 2015 at 5:31 PM, Antoon Pardon
>> <antoon.pardon at rece.vub.ac.be> wrote:
>>>
>>> I would say, that someone should get over himself.
>>> Traceback are not the only or even the most useful
>>> tool for debugging code. The current stack trace
>>> doesn't even contain the value's of the variables
>>> on the stack. So in case of Terry Reedy's example
>>> that stack trace would IMO have been next to useless.
>> Actually, they do contain all of that (at least, they do in Py3 - not
>> sure about Py2 as I haven't checked). You can poke around with the
>> locals at every point on the stack:
>
> Fine, I should have been more clear.
>
> The stack trace as it is generally produced on stderr after an uncought
> exception, doesn't contain the values of the variables on the stack.

Sure. So you catch it at top level and grab whatever info you need. In
some frameworks, this is already done for you - an uncaught exception
from application code drops you into a debugger that lets you explore
and even execute code at any level in the stack.

This would be destroyed by automated tail call optimization.

ChrisA


More information about the Python-list mailing list