MCPcopy Index your code
hub / github.com/python/cpython / test_store_attr_with_hint

Method test_store_attr_with_hint

Lib/test/test_opcache.py:1669–1690  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1667 @cpython_only
1668 @requires_specialization
1669 def test_store_attr_with_hint(self):
1670 class C:
1671 pass
1672
1673 c = C()
1674 for i in range(_testinternalcapi.SHARED_KEYS_MAX_SIZE - 1):
1675 setattr(c, f"_{i}", None)
1676
1677 @reset_code
1678 def set_value(n):
1679 for i in range(n):
1680 c.x = i
1681
1682 set_value(_testinternalcapi.SPECIALIZATION_THRESHOLD)
1683
1684 self.assert_specialized(set_value, "STORE_ATTR_WITH_HINT")
1685 self.assert_no_opcode(set_value, "STORE_ATTR")
1686
1687 # Adding a property for 'x' should unspecialize it.
1688 C.x = property(lambda self: None, lambda self, x: None)
1689 set_value(_testinternalcapi.SPECIALIZATION_COOLDOWN)
1690 self.assert_no_opcode(set_value, "STORE_ATTR_WITH_HINT")
1691
1692 @cpython_only
1693 @requires_specialization

Callers

nothing calls this directly

Calls 4

propertyClass · 0.85
assert_specializedMethod · 0.80
assert_no_opcodeMethod · 0.80
CClass · 0.70

Tested by

no test coverage detected