[issue43760] The DISPATCH() macro is not as efficient as it could be (move PyThreadState.use_tracing)
STINNER Victor
report at bugs.python.org
Mon Nov 8 12:16:37 EST 2021
STINNER Victor <vstinner at python.org> added the comment:
greenlet now uses PyThreadState_EnterTracing() and PyThreadState_LeaveTracing() rather than accessing directly use_tracing:
https://github.com/python-greenlet/greenlet/commit/9b49da5c7e4808bd61b992e40f5b5243bfa9be6f
On Python 3.10, it implements these functions with:
---
// bpo-43760 added PyThreadState_EnterTracing() to Python 3.11.0a2
#if PY_VERSION_HEX < 0x030B00A2 && !defined(PYPY_VERSION)
static inline void PyThreadState_EnterTracing(PyThreadState *tstate)
{
tstate->tracing++;
#if PY_VERSION_HEX >= 0x030A00A1
tstate->cframe->use_tracing = 0;
#else
tstate->use_tracing = 0;
#endif
}
#endif
// bpo-43760 added PyThreadState_LeaveTracing() to Python 3.11.0a2
#if PY_VERSION_HEX < 0x030B00A2 && !defined(PYPY_VERSION)
static inline void PyThreadState_LeaveTracing(PyThreadState *tstate)
{
tstate->tracing--;
int use_tracing = (tstate->c_tracefunc != NULL
|| tstate->c_profilefunc != NULL);
#if PY_VERSION_HEX >= 0x030A00A1
tstate->cframe->use_tracing = use_tracing;
#else
tstate->use_tracing = use_tracing;
#endif
}
#endif
---
This code was copied from my https://github.com/pythoncapi/pythoncapi_compat project. (I wrote the greenlet change.)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43760>
_______________________________________
More information about the Python-bugs-list
mailing list