[issue38500] Provide a way to get/set PyInterpreterState.frame_eval without needing to access interpreter internals

Fabio Zadrozny report at bugs.python.org
Mon Nov 4 06:07:34 EST 2019


Fabio Zadrozny <fabioz at users.sourceforge.net> added the comment:

@Mark Shannon what I do is change the code object of the frame about to be evaluated to add a programmatic breakpoint, to avoid the need to have the trace function set at contexts that would need to be traced (after changing the frame.f_code it goes on to call the regular _PyEval_EvalFrameDefault), so, the user-code runs at full speed on all contexts (there's still added overhead on a function call to decide if the code object needs to be changed, but that'd happen on the regular tracing code too).

Note that this does not change the semantics of anything as it calls the regular _PyEval_EvalFrameDefault, so, the worries you're listing shouldn't be a concern in this particular use-case.

Also note that until Python 3.7 this was easy to change, and that's still possible in Python 3.8 (the only thing is that now it's less straightforward).

Note that my use is much simpler that the original intent of the frame evaluator -- my use case could be solved by having a callback to change the code object before the frame execution -- but as far as I know, right now, the way to do that is through the frame evaluation API.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38500>
_______________________________________


More information about the Python-bugs-list mailing list