8000 gh-120144: Disable the CALL event when possible to achieve zero overh… · python/cpython@e356468 · GitHub
[go: up one dir, main page]

Skip to content

Commit e356468

Browse files
gh-120144: Disable the CALL event when possible to achieve zero overhead pdb (#131390)
1 parent 883c2f6 commit e356468

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Lib/bdb.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,12 @@ def dispatch_call(self, frame, arg):
342342
self.botframe = frame.f_back # (CT) Note that this may also be None!
343343
return self.trace_dispatch
344344
if not (self.stop_here(frame) or self.break_anywhere(frame)):
345-
# No need to trace this function
345+
# We already know there's no breakpoint in this function
346+
# If it's a next/until/return command, we don't need any CALL event
347+
# and we don't need to set the f_trace on any new frame.
348+
# If it's a step command, it must either hit stop_here, or skip the
349+
# whole module. Either way, we don't need the CALL event here.
350+
self.disable_current_event()
346351
return # None
347352
# Ignore call events in generator except when stepping.
348353
if self.stopframe and frame.f_code.co_flags & GENERATOR_AND_COROUTINE_FLAGS:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Disable ``CALL`` event in :mod:`bdb` in ``monitoring`` backend when we don't need any new events on the code object to get a better performance.

0 commit comments

Comments
 (0)
0