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

Class LoadLiteral

mypyc/ir/ops.py:836–869  ·  view source on GitHub ↗

Load a Python literal object (dest = 'foo' / b'foo' / ...). This is used to load a static PyObject * value corresponding to a literal of one of the supported types. Tuple / frozenset literals must contain only valid literal values as items. NOTE: You can use this to load boxed (Py

Source from the content-addressed store, hash-verified

834
835@final
836class LoadLiteral(RegisterOp):
837 """Load a Python literal object (dest = 'foo' / b'foo' / ...).
838
839 This is used to load a static PyObject * value corresponding to
840 a literal of one of the supported types.
841
842 Tuple / frozenset literals must contain only valid literal values as items.
843
844 NOTE: You can use this to load boxed (Python) int objects. Use
845 Integer to load unboxed, tagged integers or fixed-width,
846 low-level integers.
847
848 For int literals, both int_rprimitive (CPyTagged) and
849 object_primitive (PyObject *) are supported as rtype. However,
850 when using int_rprimitive, the value must *not* be small enough
851 to fit in an unboxed integer.
852 """
853
854 error_kind = ERR_NEVER
855 is_borrowed = True
856
857 def __init__(self, value: LiteralValue, rtype: RType, line: int = -1) -> None:
858 super().__init__(line)
859 self.value = value
860 self.type = rtype
861
862 def sources(self) -> list[Value]:
863 return []
864
865 def set_sources(self, new: list[Value]) -> None:
866 assert not new
867
868 def accept(self, visitor: OpVisitor[T]) -> T:
869 return visitor.visit_load_literal(self)
870
871
872@final

Callers 13

precompute_set_literalFunction · 0.90
boxMethod · 0.90
_vectorcall_keywordsMethod · 0.90
load_intMethod · 0.90
load_strMethod · 0.90
load_bytesMethod · 0.90
load_complexMethod · 0.90

Calls

no outgoing calls

Tested by 2

Used in the wild real call sites across dependent graphs

searching dependent graphs…