]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.14] gh-139103: fix free-threading `dataclass.__init__` perf issue (gh-141596)...
authorSam Gross <colesbury@gmail.com>
Wed, 19 Nov 2025 15:00:51 +0000 (10:00 -0500)
committerGitHub <noreply@github.com>
Wed, 19 Nov 2025 15:00:51 +0000 (15:00 +0000)
commitb7c25eabd6d93e745c7216b42d026e6a36795724
treeefd8e293e2b77e3d3a7f4a7aee42001cb0d32b0a
parent8c796889ff85611cc1cfcc93a2793b92579f2662
[3.14] gh-139103: fix free-threading `dataclass.__init__` perf issue (gh-141596) (gh-141750)

The dataclasses `__init__` function is generated dynamically by a call to `exec()` and so doesn't have deferred reference counting enabled. Enable deferred reference counting on functions when assigned as an attribute to type objects to avoid reference count contention when creating dataclass instances.
(cherry picked from commit ce791541769a41beabec0f515cd62e504d46ff1c)

Co-authored-by: Edward Xu <xuxiangad@gmail.com>
Misc/NEWS.d/next/Core_and_Builtins/2025-11-15-23-58-23.gh-issue-139103.9cVYJ0.rst [new file with mode: 0644]
Objects/typeobject.c
Tools/ftscalingbench/ftscalingbench.py