You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reuse code objects for similar dataclass definitions #100930
A little over a year ago, @dabeaz came up with a cool way of speeding up dataclass creation by avoiding unnecessary exec calls. Essentially, his proof-of-concept dataklasses module caches code objects for methods of "similarly-shaped" dataclasses, and patches them with the correct names:
I have a working prototype of a similar idea for the stdlib dataclasses module over in #92650. It basically doubles the speed of dataclass definitions.
Activity
ssweber commentedon Jul 17, 2023
I’ve been looking at dataclasses and this interests me. What would need to happen to take this over the finish-line?
ericvsmith commentedon Jul 17, 2023
For starters, an analysis of memory usage and cache hit ratio for common dataclass usage patterns.
ssweber commentedon Jul 17, 2023
Thanks! I’m assuming this would take some legwork, as pyperformance lacks a dataclass benchmark (if that issue is still relevant)?
I admit to not being super knowledgeable on the subject, but I like digging into topics. I’ll report back when I have more to contribute.
brandtbucher commentedon Nov 21, 2023
Closing in favor of #109870, which is the current direction
dataclassesseems to be heading in.ssweber commentedon Nov 25, 2023
From my understanding, this could be complementary with the combined exec rework.
Combined exec speeds up initial creation, this could further speed up creation of subsequent similar dataclasses.
Maybe once that has landed, we could rework this if there is interest.