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

Method visit_inc_ref

mypyc/codegen/emitfunc.py:645–662  ·  view source on GitHub ↗
(self, op: IncRef)

Source from the content-addressed store, hash-verified

643 )
644
645 def visit_inc_ref(self, op: IncRef) -> None:
646 if (
647 isinstance(op.src, Box)
648 and (is_none_rprimitive(op.src.src.type) or is_bool_or_bit_rprimitive(op.src.src.type))
649 and HAVE_IMMORTAL
650 ):
651 # On Python 3.12+, None/True/False are immortal, and we can skip inc ref
652 return
653
654 if isinstance(op.src, LoadLiteral) and HAVE_IMMORTAL:
655 value = op.src.value
656 # We can skip inc ref for immortal literals on Python 3.12+
657 if type(value) is int and -5 <= value <= 256:
658 # Small integers are immortal
659 return
660
661 src = self.reg(op.src)
662 self.emit_inc_ref(src, op.src.type)
663
664 def visit_dec_ref(self, op: DecRef) -> None:
665 src = self.reg(op.src)

Callers

nothing calls this directly

Calls 6

regMethod · 0.95
emit_inc_refMethod · 0.95
is_none_rprimitiveFunction · 0.90
isinstanceFunction · 0.85
typeClass · 0.85

Tested by

no test coverage detected