forked from cython/cython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add freethreading_compatible directive to set Py_mod_gil slot
- Loading branch information
1 parent
50fb5cf
commit 4990181
Showing
4 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
PYTHON setup.py build_ext --inplace | ||
PYTHON -c "import default; default.test()" | ||
PYTHON -c "import compatible; compatible.test()" | ||
PYTHON -c "import incompatible; incompatible.test()" | ||
|
||
######## setup.py ######## | ||
|
||
from Cython.Build.Dependencies import cythonize | ||
from distutils.core import setup | ||
|
||
ext_modules = [] | ||
|
||
# Test language_level specified in the cythonize() call | ||
ext_modules += cythonize("default.py") | ||
ext_modules += cythonize("compatible.py") | ||
ext_modules += cythonize("incompatible.py") | ||
|
||
setup(ext_modules=ext_modules) | ||
|
||
######## default.py ######## | ||
|
||
def test(): | ||
import sys | ||
assert sys._is_gil_enabled() | ||
|
||
######## compatible.py ######## | ||
|
||
# cython: freethreading_compatible=True | ||
|
||
def test(): | ||
import sys | ||
assert not sys._is_gil_enabled() | ||
|
||
######## incompatible.py ######## | ||
|
||
# cython: freethreading_compatible=False | ||
|
||
def test(): | ||
import sys | ||
assert sys._is_gil_enabled() |