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

Function cache_completed_module

include/pybind11/pybind11.h:1523–1529  ·  view source on GitHub ↗

Add successfully initialized a module object to the internal cache. The module must have a __spec__ attribute with a name attribute. */

Source from the content-addressed store, hash-verified

1521The module must have a __spec__ attribute with a name attribute.
1522*/
1523inline void cache_completed_module(pybind11::object const &mod) {
1524 dict state = detail::get_python_state_dict();
1525 if (!state.contains("__pybind11_module_cache")) {
1526 state["__pybind11_module_cache"] = dict();
1527 }
1528 state["__pybind11_module_cache"][mod.attr("__spec__").attr("name")] = mod;
1529}
1530
1531/*
1532A Py_mod_create slot function which will return the previously created module from the cache if one

Callers

nothing calls this directly

Calls 4

get_python_state_dictFunction · 0.85
dictClass · 0.85
attrMethod · 0.80
containsMethod · 0.45

Tested by

no test coverage detected