Skip to content

Commit 01b5da4

Browse files
committed
Document Cython's freethreading_compatible directive
1 parent 48b28b3 commit 01b5da4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/porting.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ Extension modules need to explicitly indicate they support running with the GIL
2222
disabled, otherwise a warning is printed and the GIL is re-enabled at runtime
2323
after importing a module that does not support the GIL.
2424

25-
!!! note
26-
27-
Currently it is not possible for extensions written in Cython to declare
28-
they support running without the GIL. Work is under way to add support
29-
(see [cython#6242](https://github.com/cython/cython/pull/6242)).
30-
3125
C++ extension modules making use of `pybind11` can easily declare support for
3226
running with the GIL disabled via the
3327
[`gil_not_used`](https://pybind11.readthedocs.io/en/stable/reference.html#_CPPv4N7module_23create_extension_moduleEPKcPKcP10module_def16mod_gil_not_used)
3428
argument to `create_extension_module`.
3529

30+
Starting with Cython 3.1.0 (only available via the nightly wheels), extension modules
31+
written in Cython can also do so using the
32+
[`freethreading_compatible`](https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#compiler-directives) compiler directive. It can be enabled either
33+
per module or globally by adding `-Xfreethreading_comparible=True` to the Cython
34+
arguments via the project's build system.
35+
3636
C or C++ extension modules using multi-phase initialization can specify the
3737
[`Py_mod_gil`](https://docs.python.org/3.13/c-api/module.html#c.Py_mod_gil)
3838
module slot like this:

0 commit comments

Comments
 (0)