Skip to content

Reuse code objects for similar dataclass definitions #100930

@brandtbucher

Description

@brandtbucher

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:

https://github.com/dabeaz/dataklasses

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.

CC @ericvsmith

Linked PRs

Metadata

Metadata

Assignees

Labels

3.12only security fixesperformancePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directory

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions