cython icon indicating copy to clipboard operation
cython copied to clipboard

Add a C macro to configure "Py_mod_gil" at C compile time

Open scoder opened this issue 2 weeks ago • 1 comments

I found a use case for setting Py_mod_gil differently in Py3.13 and Py3.14, but regenerating the whole C file just to switch between them is rather wasteful. So here's a new C macro CYTHON_FREETHREADING_COMPATIBLE that allows defining the setting from the outside.

Having a directive is still useful because we don't want to require the C macro to be set. It should usually have a fixed value for a given module.

scoder avatar Dec 11 '25 14:12 scoder

I can see this being useful. I think the directive should still be the default recommendation. But I could see some things being version dependent (especially while free-threading is still experimental)

da-woods avatar Dec 11 '25 20:12 da-woods

Closed in https://github.com/cython/cython/pull/7404 (3.2.x)

scoder avatar Dec 12 '25 09:12 scoder