Skip to content

Combine dataclass exec calls #109870

Closed
@ssweber

Description

@ssweber

Feature or enhancement

Proposal:

As mentioned here, dataclass definition can possibly be sped up by combining the multiple exec calls into one.

I have two versions, and I found that this results in either a 1.1-1.22 1.26, or 1.37 speedup versus main (old time / new time)

version 1 combines the exec calls by passing a list of name/txt/locals from each function definition.
version 2 simplifies the final exec call to avoid __create_fn__, but I'm not experienced to know if that is safe.
(see below for open pr)

@ericvsmith Let me know if this is a suitable change, and if so, which version we should open a pr based on.

Thank you!

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

https://discuss.python.org/t/improving-dataclasses-startup-performance/15442/18

Linked PRs

Metadata

Metadata

Assignees

Labels

performancePerformance or resource usagestdlibPython modules in the Lib dirtype-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions