Repository navigation
Feat: Free-threaded-safe TypedPython modules declare Py_MOD_GIL_NOT_USED (#159) - #209
Merged
Merged
Conversation
…tp-free-threaded # Conflicts: # python-multiplatform-ksp/src/main/python/typedpython/runtime/API.md
This was referenced Oct 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #159
Defect fixed: importing any compiled TypedPython module on a free-threaded build turned the GIL back on for the whole process, because the module declared no
Py_mod_gilslot. Without the GIL, the runtime's shared state also raced.Feature added:
{Py_mod_gil, Py_MOD_GIL_NOT_USED}(underPy_GIL_DISABLED).runtime/API.md, "Free-threaded CPython"):tp_depth, the poll countdown,tp_snapshot_depth;tp_version_tagread;PyDict_GetItemRef,PyEval_GetFrameBuiltins).Unchanged on purpose: functions holding an array snapshot still defer polls (#141), pending the decision in #152 on the changed-after-poll case. A long compiled array loop therefore delays other threads' stop-the-world until it returns. That is a liveness delay; results are unaffected.
Tests added:
test_free_threaded.py, 23 tests.PYTHON_GIL=0: torn reads, a mis-rotated shared list, stale class bindings and lost deopt counts.Tests changed:
tp_shim.cdeclares its GIL slot.CI:
typedpython.ymluses 3.15t in all three jobs. The Linux ASan job and the macOS app-fixture job have not run on 3.15t yet; they will run on the develop push.Verification (local, CPython 3.15.0rc1 free-threaded,
sys._is_gil_enabled()False): the full TypedPython suite with RuntimeWarning as error: 989 passed, 3 skipped. The branch also contains develop and #207.