diff options
author | Tian Gao <gaogaotiantian@hotmail.com> | 2024-05-03 18:49:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-03 18:49:24 (GMT) |
commit | 9c14ed06188aa4d462cd0fc4218c6023f9bf03cb (patch) | |
tree | 1e60a736e9b626706110a8f1600a20ef8c8b3827 /Python/ceval_macros.h | |
parent | 998c3856c1e922ece806c162858dc587a1e92e02 (diff) | |
download | cpython-9c14ed06188aa4d462cd0fc4218c6023f9bf03cb.zip cpython-9c14ed06188aa4d462cd0fc4218c6023f9bf03cb.tar.gz cpython-9c14ed06188aa4d462cd0fc4218c6023f9bf03cb.tar.bz2 |
gh-107674: Improve performance of `sys.settrace` (GH-117133)
* Check tracing in RESUME_CHECK
* Only change to RESUME_CHECK if not tracing
Diffstat (limited to 'Python/ceval_macros.h')
-rw-r--r-- | Python/ceval_macros.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Python/ceval_macros.h b/Python/ceval_macros.h index c88a07c..50941e4 100644 --- a/Python/ceval_macros.h +++ b/Python/ceval_macros.h @@ -358,12 +358,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); |