MCPcopy Create free account
hub / github.com/pybind/pybind11 / PYBIND11_MODULE

Function PYBIND11_MODULE

tests/test_with_catch/external_module.cpp:21–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19} // namespace
20
21PYBIND11_MODULE(external_module,
22 m,
23 py::mod_gil_not_used(),
24 py::multiple_interpreters::per_interpreter_gil()) {
25 // At least one test ("Single Subinterpreter") wants to reset
26 // internals. We have separate local internals because we are a
27 // separate DSO, so ours need to be reset too!
28 unsafe_reset_local_internals();
29 class A {
30 public:
31 explicit A(int value) : v{value} {};
32 int v;
33 };
34
35 py::class_<A>(m, "A").def(py::init<int>()).def_readwrite("value", &A::v);
36
37 m.def("internals_at",
38 []() { return reinterpret_cast<uintptr_t>(&py::detail::get_internals()); });
39}

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected