[issue1565525] tracebacks eat up memory by holding references to locals and globals when they are not wanted
STINNER Victor
report at bugs.python.org
Mon Sep 9 22:20:37 CEST 2013
STINNER Victor added the comment:
I tried to implement the feature as a new traceback.clear_frames() method. I tried to follow the chain of frame objects (using frame.f_back), but it does not work as expected. The method needs to follow the chain of traceback objects (tb.tb_next). So it makes sense to define a function instead of a method (a method usually only affect the object, not a chain of objects).
clear-tb-frames-2.txt:
- I didn't see the "tb" abbreviation in other places in Python, except for traceback attributes. I prefer clear_traceback_frames(). The name clear_frames() is maybe better because traceback is already known by the context (the module is called "tracback". Example: traceback.clear_frames(tb) instead of traceback.clear_traceback_frames(tb).
- The documentation is wrong: frame.clear() does not guarantee to clear *all* locals, but only *most* locals:
"F.clear(): clear most references held by the frame");
So I suggest a more permissive documentation:
"Clear most reference held by frames."
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1565525>
_______________________________________
More information about the Python-bugs-list
mailing list