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

Function globals

include/pybind11/pybind11.h:1759–1768  ·  view source on GitHub ↗

\ingroup python_builtins Return a dictionary representing the global variables in the current execution frame, or ``__main__.__dict__`` if there is no frame (usually when the interpreter is embedded).

Source from the content-addressed store, hash-verified

1757/// Return a dictionary representing the global variables in the current execution frame,
1758/// or ``__main__.__dict__`` if there is no frame (usually when the interpreter is embedded).
1759inline dict globals() {
1760#if PY_VERSION_HEX >= 0x030d0000
1761 PyObject *p = PyEval_GetFrameGlobals();
1762 return p ? reinterpret_steal<dict>(p)
1763 : reinterpret_borrow<dict>(module_::import("__main__").attr("__dict__").ptr());
1764#else
1765 PyObject *p = PyEval_GetGlobals();
1766 return reinterpret_borrow<dict>(p ? p : module_::import("__main__").attr("__dict__").ptr());
1767#endif
1768}
1769
1770PYBIND11_NAMESPACE_BEGIN(detail)
1771/// Generic support for creating new Python heap types

Callers 5

mainFunction · 0.85
evalFunction · 0.85
execFunction · 0.85
eval_fileFunction · 0.85

Calls 3

importFunction · 0.85
ptrMethod · 0.80
attrMethod · 0.80

Tested by

no test coverage detected