[Python-ideas] Standard way to get caller name and easy call stack access
sven at marnach.net
Wed Mar 28 01:29:07 CEST 2012
Jim Jewett schrieb am Tue, 27. Mar 2012, um 16:06:51 -0400:
> On Tue, Mar 27, 2012 at 12:32 PM, Sven Marnach <sven at marnach.net> wrote:
> > ... Steven D'Aprano suggested giving full access to the function
> > objects instead. The function object cannot be referenced in the
> > code object, though, because this would create reference cycles in
> > CPython.
> Not if you use weakrefs.
> And frankly, even without weakrefs, so what? Functions are typically
> immortal; waiting until gc to collect the oddballs isn't such a terrible cost.
I didn't carefully think about this one. It's impossible to reference
the function object in the code object for a different reason: there
can be many function objects corresponding to the same code object.
So the discussion whether the reference cycle is tolerable is moot --
it's impossible anyway. If we want access to the function objects
from the stack trace, the only way to go is to add a reference to
More information about the Python-ideas