-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
Description
Pdb currently have a few instances variables that are not defined in __init__.
Mainly as far as I can tell, :
self.lineno
self.stack
self.curindex
self.curframe
self.currentbp
self._user_requested_quit
(not set in Bdb, or Cmd superclass either)
This means that accessing these requires a hasattr/getattr, which we can see in the Pdb's implementation in a few places. This is a footgun for a subclasses, and in particular for IPython, in some circumstances, the gettattr start to have a non-negligible perf impact (We support things like having __debuggerskip__ = True|False in a frame, so the getattr(self, 'currentframe',...) start to get expensive.
It would be great if all those were initialized in __init__; Yes I can initialize in my __init__ subclass, but having it in CPython should benefit everybody, plus it would allow the removal of a few getattr() in CPython source directly.
Personally I care mostly about curframe, but while at it maybe do the other ones.
I am not aware of anything that uses the fact the attribute is missing.