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

Method test_store_attr_slot

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

Source from the content-addressed store, hash-verified

1624 @cpython_only
1625 @requires_specialization
1626 def test_store_attr_slot(self):
1627 class C:
1628 __slots__ = ['x']
1629
1630 def set_slot(n):
1631 c = C()
1632 for i in range(n):
1633 c.x = i
1634
1635 set_slot(_testinternalcapi.SPECIALIZATION_THRESHOLD)
1636
1637 self.assert_specialized(set_slot, "STORE_ATTR_SLOT")
1638 self.assert_no_opcode(set_slot, "STORE_ATTR")
1639
1640 # Adding a property for 'x' should unspecialize it.
1641 C.x = property(lambda self: None, lambda self, x: None)
1642 set_slot(_testinternalcapi.SPECIALIZATION_COOLDOWN)
1643 self.assert_no_opcode(set_slot, "STORE_ATTR_SLOT")
1644
1645 @cpython_only
1646 @requires_specialization

Callers

nothing calls this directly

Calls 3

propertyClass · 0.85
assert_specializedMethod · 0.80
assert_no_opcodeMethod · 0.80

Tested by

no test coverage detected