Skip to content

Commit

Permalink
docs: extend PYBIND11_MODULE documentation, mention `mod_gil_not_us…
Browse files Browse the repository at this point in the history
…ed` (#5250)

This follows up on PR 5148, which introduced support for free-threaded CPython.
  • Loading branch information
rgommers committed Jul 18, 2024
1 parent 43de801 commit dbf848a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions include/pybind11/detail/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,22 @@ PYBIND11_WARNING_POP
return "Hello, World!";
});
}
The third macro argument is optional (available since 2.13.0), and can be used to
mark the extension module as safe to run without the GIL under a free-threaded CPython
interpreter. Passing this argument has no effect on other interpreters.
.. code-block:: cpp
PYBIND11_MODULE(example, m, py::mod_gil_not_used()) {
m.doc() = "pybind11 example module safe to run without the GIL";
// Add bindings here
m.def("foo", []() {
return "Hello, Free-threaded World!";
});
}
\endrst */
#define PYBIND11_MODULE(name, variable, ...) \
static ::pybind11::module_::module_def PYBIND11_CONCAT(pybind11_module_def_, name) \
Expand Down

0 comments on commit dbf848a

Please sign in to comment.