summaryrefslogtreecommitdiffstats
path: root/Python/ceval_macros.h
diff options
context:
space:
mode:
authorTian Gao <gaogaotiantian@hotmail.com>2024-02-28 15:21:42 (GMT)
committerGitHub <noreply@github.com>2024-02-28 15:21:42 (GMT)
commit0a61e237009bf6b833e13ac635299ee063377699 (patch)
tree3f4b945c0e65971740f7a0a3b4d38c2624bcd9a7 /Python/ceval_macros.h
parent9578288a3e5a7f42d1f3bec139c0c85b87775c90 (diff)
downloadcpython-0a61e237009bf6b833e13ac635299ee063377699.zip
cpython-0a61e237009bf6b833e13ac635299ee063377699.tar.gz
cpython-0a61e237009bf6b833e13ac635299ee063377699.tar.bz2
gh-107674: Improve performance of `sys.settrace` (GH-114986)
Diffstat (limited to 'Python/ceval_macros.h')
-rw-r--r--Python/ceval_macros.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/Python/ceval_macros.h b/Python/ceval_macros.h
index 0851994..6ad4195 100644
--- a/Python/ceval_macros.h
+++ b/Python/ceval_macros.h
@@ -339,12 +339,16 @@ do { \
// for an exception handler, displaying the traceback, and so on
#define INSTRUMENTED_JUMP(src, dest, event) \
do { \
- _PyFrame_SetStackPointer(frame, stack_pointer); \
- next_instr = _Py_call_instrumentation_jump(tstate, event, frame, src, dest); \
- stack_pointer = _PyFrame_GetStackPointer(frame); \
- if (next_instr == NULL) { \
- next_instr = (dest)+1; \
- goto error; \
+ if (tstate->tracing) {\
+ next_instr = dest; \
+ } else { \
+ _PyFrame_SetStackPointer(frame, stack_pointer); \
+ next_instr = _Py_call_instrumentation_jump(tstate, event, frame, src, dest); \
+ stack_pointer = _PyFrame_GetStackPointer(frame); \
+ if (next_instr == NULL) { \
+ next_instr = (dest)+1; \
+ goto error; \
+ } \
} \
} while (0);