[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>