Possibly Pythonic Tail Call Optimization (TCO/TRE)

Gregory Ewing greg.ewing at canterbury.ac.nz
Fri Jul 17 00:41:40 CEST 2015


Antoon Pardon wrote:
> On 07/16/2015 12:43 AM, Gregory Ewing wrote:
> 
>>Whatever value you choose for N, keeping only the
>>first/last N traceback frames will lead to someone
>>tearing their hair out.
> 
> I would say, that someone should get over himself.
> Traceback are not the only or even the most useful
> tool for debugging code.

They're the one thing I miss the most whenever I have
to debug something in an environment that doesn't provide
them, though,

 > My experience is, that if you need to dig that deep
> in a stack trace, to find the information you need, you
> get it easier and faster by turning debug level logging
> on and going through the logs. YMMV.

That only helps if the code logs the information you need
or can be easily modified to do so. In my case, it didn't
and couldn't.

> I also have to wonder, In my suggestion you would only start
> to loose traceback records after six consecutive tail calls.
> That IMO strongly suggest a loop.

Not necessarily. Chains of calls very often go more than 6
levels deep. It's less likely that they would all happen to
be tail calls, but it could happen without there being any
looping or recursion involved. And the source of the problem
you're trying to debug could be in *any* of the intermediate
calls, not necessarily the first or last 3.

-- 
Greg


More information about the Python-list mailing list