Lazy traceback objects #407
kumaraditya303
started this conversation in
Ideas
Replies: 2 comments 7 replies
-
What do we need to save in order to later have all the information we need to construct the traceback? |
Beta Was this translation helpful? Give feedback.
3 replies
-
@kumaraditya303 can you fill out the details. Specifically, what objects would be allocated when? As a simple first step, we could compute the line number lazily from |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The idea here is to avoid creating traceback and frame objects when an exception is raised unless required. Currently, traceback objects are created eagerly and since traceback objects hold reference to frame objects, expensive
PyFrameObject*
are created.As an example:
Here even though the traceback object was not accessed, it was created. This applies to all the exceptions as such
StopIteration
etc.In the new optimized design we may lazily create a traceback if it is accessed by replacing
__traceback__
with a descriptor and cache its value once traceback is created. This would avoid creation of most traceback and frame objects and should speed up exception handling. Traceback and frames are GC heavy objects so this should also help GC.Beta Was this translation helpful? Give feedback.
All reactions