Skip to content

Commit

Permalink
pythongh-128691: Use deferred reference counting on _thread._local
Browse files Browse the repository at this point in the history
After this change, the "thread_local_read" micro benchmark in
Tools/ftscalingbench/ftscalingbench.py now scales well when multiple
threads read from the same thread-local variable.
  • Loading branch information
colesbury committed Jan 9, 2025
1 parent 33deca3 commit af23793
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions Modules/_threadmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,7 @@ local_new(PyTypeObject *type, PyObject *args, PyObject *kw)
Py_DECREF(localsdict);
Py_DECREF(sentinel_wr);

_PyObject_SetDeferredRefcount((PyObject *)self);
return (PyObject *)self;

err:
Expand Down

0 comments on commit af23793

Please sign in to comment.