There's a lot of code which accesses the current interpreter state especially under free-threading via PyInterpreterState_Get. Currently to lookup interpreter state first the thread state is accessed then read by ts->interp but it can be optimized to be stored in a thread local variable _Py_tss_current_interp so that it can be read directly.
Linked PRs
There's a lot of code which accesses the current interpreter state especially under free-threading via
PyInterpreterState_Get. Currently to lookup interpreter state first the thread state is accessed then read byts->interpbut it can be optimized to be stored in a thread local variable_Py_tss_current_interpso that it can be read directly.Linked PRs
HAVE_THREAD_LOCALchecks in pystate.c #140547_PyInterpreterState_GETfor type lock #140584pycore_pystate.hwhenHAVE_THREAD_LOCALis not defined #140623