bpo-44348: Move trace-info to thread-state by markshannon · Pull Request #26623 · python/cpython (original) (raw)
This reduces the C stack consumption of _PyEval_EvalFrameDefault
a bit.
Also fixes a subtle bug when tracing is turned on in the middle of the line, and the last traced line was after the current line.
Previously, this resulting in tracing the current line, as the interpreter perceived this as a backwards branch. Which was wrong.
This PR fixes it by making the decision of whether to trace based solely on the current instruction and the last one executed (in the same frame).