Repository navigation
Conversation
|
Thie adds nontrivial refcounting contention on the FT build. What is the effect on micro and macro benchmarks for regular types? |
|
I measured it on free-threaded release builds (
Single-threaded, only the paths that miss specialization pay for it:
On the default build (plain pyperformance, 18 benchmarks on the FT build: geometric mean 1.01x slower, with 1-3% on richards, json_dumps, and nbody. A second run of main against itself moved by up to 3%, so the macro difference is inside the noise on this machine.
|
|
Setting things is less common than getting. I am concerned by that and I know that we already had a similar issue about that and @kumaraditya303 was also concerned. |
_PyObject_GenericGetAttrWithDict()keeps a borrowedtp = Py_TYPE(obj), but hashing or comparing astrsubclass name can run Python code that reassignsobj.__class__and lets the GC free the old type. The lookup then keeps usingtp. This takes a reference to the type for the duration of the lookup, the same way_PyObject_GenericSetAttrWithDict()already does with_Py_INCREF_TYPE()._PyObject_GetMethod()and_PyObject_GetMethodStackRef()had the same problem when astrsubclass key in the instance dict runs__eq__during the dict lookup, so they take the same reference.Fixes #159098