diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py index 7a24f8a9e5ccee..91f48ca189db44 100644 --- a/Lib/dataclasses.py +++ b/Lib/dataclasses.py @@ -784,7 +784,7 @@ def _get_field(cls, a_name, a_type, default_kw_only): f = field(default=default) # Only at this point do we know the name and the type. Set them. - f.name = a_name + f.name = sys.intern(a_name) f.type = a_type # Assume it's a normal field until proven otherwise. We're next diff --git a/Misc/NEWS.d/next/Library/2023-12-03-12-00-38.gh-issue-112653.Q7MK-5.rst b/Misc/NEWS.d/next/Library/2023-12-03-12-00-38.gh-issue-112653.Q7MK-5.rst new file mode 100644 index 00000000000000..37acbcbe189808 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-12-03-12-00-38.gh-issue-112653.Q7MK-5.rst @@ -0,0 +1 @@ +Intern field names of ``dataclass`` to improve performance. Patch by Xuehai Pan.