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

Function get_cached_module

include/pybind11/pybind11.h:1506–1516  ·  view source on GitHub ↗

Return a borrowed reference to the named module if it has been successfully initialized within this interpreter before. nullptr if it has not been successfully initialized. */

Source from the content-addressed store, hash-verified

1504interpreter before. nullptr if it has not been successfully initialized.
1505*/
1506inline PyObject *get_cached_module(pybind11::str const &nameobj) {
1507 dict state = detail::get_python_state_dict();
1508 if (!state.contains("__pybind11_module_cache")) {
1509 return nullptr;
1510 }
1511 dict cache = state["__pybind11_module_cache"];
1512 if (!cache.contains(nameobj)) {
1513 return nullptr;
1514 }
1515 return cache[nameobj].ptr();
1516}
1517
1518/*
1519Add successfully initialized a module object to the internal cache.

Callers 1

cached_create_moduleFunction · 0.85

Calls 3

get_python_state_dictFunction · 0.85
ptrMethod · 0.80
containsMethod · 0.45

Tested by

no test coverage detected