Add free-threaded CPython (3.14t) support - #858
Conversation
- Mark all Cython extensions with freethreading_compatible=True so the interpreter no longer re-enables the GIL when numcodecs is imported - Require Cython>=3.1, needed for the freethreading_compatible directive - blosc: replace the lazily created multiprocessing.Lock (and get_mutex()) with a module-level threading.Lock, reset in forked children via os.register_at_fork - blosc: take the lock in _init, _destroy, set_nthreads and the global context path of decompress, so blosc_set_nthreads cannot re-create the global context while another thread is using it - blosc: compute the compressor list once at import; blosc_list_compressors() fills a static buffer without locking and was called on every compress() - CI: add 3.14t to the test matrix, installing without pcodec, zfpy and google_crc32c which do not ship free-threaded wheels yet - Wheels: enable cpython-freethreading in cibuildwheel, build cp314t-* wheels, and assert in the wheel test that the GIL is not re-enabled on free-threaded builds
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #858 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 27 27
Lines 905 905
=========================================
Hits 905 905 🚀 New features to boost your workflow:
|
|
I dropped |
|
I don't know this part of the code very well so I'm acting as a conduit for Claude here. This is the review from claude: 🤖 AI text below 🤖 Built against free-threaded 3.14.7 locally (macOS arm64, Cython 3.3):
Required before merge:
|
|
"I" can make the required changes if you don't mind |
Yes you can make the changes, they all seem fine to me. |
- docs/release.md: document 3.14t support, the Cython>=3.1 build requirement, the removal of numcodecs.blosc.get_mutex, and the changed fallback on platforms without multiprocessing.Lock - tests/test_free_threading.py: assert in a fresh interpreter that importing numcodecs does not re-enable the GIL on free-threaded builds - tests/test_blosc.py: regression test racing compress/decompress on the global context against set_nthreads; segfaults on main, passes with the new locking Assisted-by: ClaudeCode:claude-fable-5-1 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Assisted-by: ClaudeCode:claude-fable-5-1 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Hello, I am a CPython Core Developer working on free-threading support. This PR adds support for free-threading on 3.14t+ (#749).
Changes:
TODO: