File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -462,6 +462,22 @@ PYBIND11_WARNING_POP
462
462
return "Hello, World!";
463
463
});
464
464
}
465
+
466
+ The third macro argument is optional (available since 2.13.0), and can be used to
467
+ mark the extension module as safe to run without the GIL under a free-threaded CPython
468
+ interpreter. Passing this argument has no effect on other interpreters.
469
+
470
+ .. code-block:: cpp
471
+
472
+ PYBIND11_MODULE(example, m, py::mod_gil_not_used()) {
473
+ m.doc() = "pybind11 example module safe to run without the GIL";
474
+
475
+ // Add bindings here
476
+ m.def("foo", []() {
477
+ return "Hello, Free-threaded World!";
478
+ });
479
+ }
480
+
465
481
\endrst */
466
482
#define PYBIND11_MODULE (name, variable, ...) \
467
483
static ::pybind11::module_::module_def PYBIND11_CONCAT (pybind11_module_def_, name) \
You can’t perform that action at this time.
0 commit comments