File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import threading
66import types
77import unittest
8- import weakref
98from test .support import (threading_helper , check_impl_detail ,
109 requires_specialization , Py_GIL_DISABLED ,
11- cpython_only , requires_jit_disabled , reset_code ,
12- gc_collect )
10+ cpython_only , requires_jit_disabled , reset_code )
1311from test .support .import_helper import import_module
1412
1513# Skip this module on other interpreters, it is cpython specific:
@@ -2258,22 +2256,16 @@ class Holder:
22582256 attr = Value ()
22592257
22602258 value = Holder .attr
2261- wr = weakref .ref (value )
22622259
22632260 def load_class_attr ():
22642261 for _ in range (_testinternalcapi .SPECIALIZATION_THRESHOLD ):
22652262 x = Holder .attr
2266- assert x is value
22672263
22682264 # Ensure we specialise from a non owning thread
22692265 threading_helper .run_concurrently (load_class_attr , nthreads = 1 )
22702266 self .assert_no_opcode (load_class_attr , "LOAD_ATTR_CLASS" )
22712267 self .assertTrue (_testinternalcapi .has_deferred_refcount (value ))
22722268
2273- del load_class_attr , Holder , value
2274- gc_collect ()
2275- self .assertIsNone (wr ())
2276-
22772269
22782270if __name__ == "__main__" :
22792271 unittest .main ()
Original file line number Diff line number Diff line change @@ -326,15 +326,9 @@ def enum_attr():
326326 MyEnum .Z
327327
328328
329- class _SharedAttrValue :
330- pass
331-
332329class MyClassWithSharedAttr :
333- # A class attribute whose value is an instance of a *different* class.
334- # Reading it from multiple threads did not scale because LOAD_ATTR_CLASS
335- # cannot specialize this case (the value's type is not the owner class),
336- # leaving the shared value's reference count contended on every read.
337- attr = _SharedAttrValue ()
330+ # instance of another heap type: LOAD_ATTR_CLASS can't specialize this
331+ attr = MyObject ()
338332
339333@register_benchmark
340334def class_attribute ():
You can’t perform that action at this time.
0 commit comments