docs: show nogil in most examples (#5770)

Created using [mini-swe-agent](https://mini-swe-agent.com) and the propmt:

I'd like to find usages of PYBIND11_MODULE in the docs folder and add py::mod_gil_not_used() as a third argument if there ar
e only two arguments. These are examples, and it's really a good idea to always include that now.

I removed a few of the changes.

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
This commit is contained in:
Henry Schreiner
2025-07-27 23:08:11 -06:00
committed by GitHub
parent 33533ff3f8
commit 6972597c9b
9 changed files with 15 additions and 16 deletions

View File

@@ -27,7 +27,7 @@ The binding code for ``Pet`` looks as follows:
namespace py = pybind11;
PYBIND11_MODULE(example, m) {
PYBIND11_MODULE(example, m, py::mod_gil_not_used()) {
py::class_<Pet>(m, "Pet")
.def(py::init<const std::string &>())
.def("setName", &Pet::setName)
@@ -480,7 +480,7 @@ management. For example, ownership is inadvertently transferred here:
std::shared_ptr<Child> child;
};
PYBIND11_MODULE(example, m) {
PYBIND11_MODULE(example, m, py::mod_gil_not_used()) {
py::class_<Child, std::shared_ptr<Child>>(m, "Child");
py::class_<Parent, std::shared_ptr<Parent>>(m, "Parent")