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

Method test_store_attr_instance_value

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

Source from the content-addressed store, hash-verified

1645 @cpython_only
1646 @requires_specialization
1647 def test_store_attr_instance_value(self):
1648 class C:
1649 pass
1650
1651 @reset_code
1652 def set_value(n):
1653 c = C()
1654 for i in range(n):
1655 c.x = i
1656
1657 set_value(_testinternalcapi.SPECIALIZATION_THRESHOLD)
1658
1659 self.assert_specialized(set_value, "STORE_ATTR_INSTANCE_VALUE")
1660 self.assert_no_opcode(set_value, "STORE_ATTR")
1661
1662 # Adding a property for 'x' should unspecialize it.
1663 C.x = property(lambda self: None, lambda self, x: None)
1664 set_value(_testinternalcapi.SPECIALIZATION_COOLDOWN)
1665 self.assert_no_opcode(set_value, "STORE_ATTR_INSTANCE_VALUE")
1666
1667 @cpython_only
1668 @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