[issue40522] [subinterpreters] Get the current Python interpreter state from Thread Local Storage (autoTSSkey)

STINNER Victor report at bugs.python.org
Mon Dec 28 09:25:32 EST 2020


STINNER Victor <vstinner at python.org> added the comment:

>_PyInterpreterState_GET():
>   mov    rax,QWORD PTR [rip+0x22a7dd]        # 0x743118 <_PyRuntime+568>
>   mov    rax,QWORD PTR [rax+0x10]

While working on bpo-39465, I wrote PR 20767 to optimize _PyInterpreterState_GET(): single instruction instead of two:

* Add _PyRuntimeState.interp_current member: atomic variable
* _PyThreadState_Swap() sets _PyRuntimeState.interp_current

But I failed to measure any performance difference.

----------

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


More information about the Python-bugs-list mailing list