From f4997bb3ac961d6aaf07ce650cd074e28ce6ccd0 Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Tue, 24 Sep 2024 13:08:18 -0700 Subject: gh-123923: Defer refcounting for `f_funcobj` in `_PyInterpreterFrame` (#124026) Use a `_PyStackRef` and defer the reference to `f_funcobj` when possible. This avoids some reference count contention in the common case of executing the same code object from multiple threads concurrently in the free-threaded build. --- Python/optimizer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/optimizer.c') diff --git a/Python/optimizer.c b/Python/optimizer.c index 9198e410627..bb7a90b3204 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -533,7 +533,7 @@ translate_bytecode_to_trace( { bool first = true; PyCodeObject *code = _PyFrame_GetCode(frame); - PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; + PyFunctionObject *func = _PyFrame_GetFunction(frame); assert(PyFunction_Check(func)); PyCodeObject *initial_code = code; _Py_BloomFilter_Add(dependencies, initial_code); -- cgit v1.2.3