-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow GIL to be disabled in whirlpool C extension #1344
Allow GIL to be disabled in whirlpool C extension #1344
Conversation
Thanks for looking at this already. I haven't dared try -gil yet... |
e42efd5
to
d8d1847
Compare
d8d1847
to
78a96aa
Compare
78a96aa
to
8eb20d5
Compare
Having just given myself a crash course on "multi-phase initialization", this looks ok to me. |
I've found that there's a https://docs.python.org/3.13/c-api/module.html#c.PyUnstable_Module_SetGIL |
8eb20d5
to
88646d7
Compare
I'm running emerge with |
In 3.13 python extensions need to declare support for GIL features, for example if they don't declare Py_MOD_GIL_NOT_USED then it will cause the GIL to be enabled even when python was launched in free-threaded mode. This requires "multi-phase initialization" because Py_mod_create is incompatible with m_slots. There's a PyUnstable_Module_SetGIL() function that can be used with single-phase init, but it's an unstable API, so it's better to use multi-phase init. There's no need to use PyModule_GetState() because the whirlpool module has no mutable state. Bug: https://bugs.gentoo.org/934220 Signed-off-by: Zac Medico <zmedico@gentoo.org>
88646d7
to
918f4a4
Compare
In 3.13 python extensions need to declare support for GIL features, for example if they don't declare Py_MOD_GIL_NOT_USED then it will cause the GIL to be enabled even when python was launched in free-threaded mode.
This requires "multi-phase initialization" because
Py_mod_create
is incompatible withm_slots
. There's aPyUnstable_Module_SetGIL()
function that can be used with single-phase init, but it's an unstable API, so it's better to use multi-phase init. There's no need to usePyModule_GetState()
because the whirlpool module has no mutable state.Bug: https://bugs.gentoo.org/934220