You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ENH: stats: enable free-threading support for Cython extensions #20267
Adding the module-level directive # cython: freethreading_compatible = True to astropy.stats._stats (assuming it is thread-safe) allows Astropy to run on free-threaded Python builds without re-enabling the GIL.
Currently, when running tests on a free-threaded Python build (verified on Python 3.15t), importing this module causes pytest to emit the following warning:
RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 'astropy.stats._stats', which has not declared that it can run safely without the GIL. To override this behavior and keep the GIL disabled (at your own risk), run with PYTHON_GIL=0 or -Xgil=0.
Describe the desired outcome
Add # cython: freethreading_compatible = True to astropy.stats._stats (and potentially other Cython modules if applicable) so that the module can be imported in free-threaded Python without automatically re-enabling the GIL.
Activity
pllim commentedon Aug 24, 2026
This might be part of a larger issue at #16916