MCPcopy Index your code
hub / github.com/python/mypy / load_global

Method load_global

mypyc/irbuild/builder.py:1517–1534  ·  view source on GitHub ↗

Loads a Python-level global. This takes a NameExpr and uses its name as a key to retrieve the corresponding PyObject * from the _globals dictionary in the C-generated code.

(self, expr: NameExpr)

Source from the content-addressed store, hash-verified

1515 return "." in expr.node.fullname and expr.node.fullname.split(".")[0] == "builtins"
1516
1517 def load_global(self, expr: NameExpr) -> Value:
1518 """Loads a Python-level global.
1519
1520 This takes a NameExpr and uses its name as a key to retrieve the corresponding PyObject *
1521 from the _globals dictionary in the C-generated code.
1522 """
1523 # If the global is from 'builtins', turn it into a module attr load instead
1524 if self.is_builtin_ref_expr(expr):
1525 assert expr.node, "RefExpr not resolved"
1526 return self.load_module_attr_by_fullname(expr.node.fullname, expr.line)
1527 if (
1528 self.is_native_module_ref_expr(expr)
1529 and isinstance(expr.node, TypeInfo)
1530 and not self.is_synthetic_type(expr.node)
1531 ):
1532 assert expr.fullname
1533 return self.load_native_type_object(expr.fullname)
1534 return self.load_global_str(expr.name, expr.line)
1535
1536 def load_global_str(self, name: str, line: int) -> Value:
1537 _globals = self.load_globals_dict()

Callers 1

transform_name_exprFunction · 0.45

Calls 7

is_builtin_ref_exprMethod · 0.95
is_synthetic_typeMethod · 0.95
load_global_strMethod · 0.95
isinstanceFunction · 0.85

Tested by

no test coverage detected