Skip to content

Commit

Permalink
Remove the PyFrame_FastToLocals and PyFrame_LocalsToFast calls from t…
Browse files Browse the repository at this point in the history
…he trampoline `call_target`.

Fix #336
  • Loading branch information
joerick committed Aug 26, 2024
1 parent ae998ff commit 3414b1e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pyinstrument/low_level/stat_profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ stat_profile_init(void)
static PyObject *
call_target(ProfilerState *pState, PyFrameObject *frame, int what, PyObject *arg)
{
PyFrame_FastToLocals(frame);
// note: we no longer call PyFrame_FastToLocals and PyFrame_LocalsToFast
// here, as it's only needed for python-level modification of locals,
// which a profiler doesn't need to do.

#if PY_VERSION_HEX >= 0x03090000
// vectorcall implementation could be faster, is available in Python 3.9
Expand All @@ -242,10 +244,9 @@ call_target(ProfilerState *pState, PyFrameObject *frame, int what, PyObject *arg
PyObject *result = PyObject_CallFunctionObjArgs(pState->target, (PyObject *) frame, whatstrings[what], arg == NULL ? Py_None : arg, NULL);
#endif

PyFrame_LocalsToFast(frame, 1);

if (result == NULL)
if (result == NULL) {
PyTraceBack_Here(frame);
}

return result;
}
Expand Down

0 comments on commit 3414b1e

Please sign in to comment.