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

Method init

tests/mod_per_interpreter_gil_with_singleton.cpp:53–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51 std::vector<py::handle> &get_objects() { return objects; }
52
53 static void init() {
54 // Ensure the singleton is created
55 auto &instance = get_instance();
56 (void) instance; // suppress unused variable warning
57 assert(instance.objects.size() == 7);
58 // Register cleanup at interpreter exit
59 py::module_::import("atexit").attr("register")(py::cpp_function(&MySingleton::clear));
60 }
61
62 static void clear() {
63 auto &instance = get_instance();

Callers

nothing calls this directly

Calls 4

importFunction · 0.85
cpp_functionClass · 0.85
attrMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected