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
A little over a year ago, @dabeaz came up with a cool way of speeding up
dataclasscreation by avoiding unnecessaryexeccalls. Essentially, his proof-of-conceptdataklassesmodule 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
dataclassesmodule over in #92650. It basically doubles the speed ofdataclassdefinitions.CC @ericvsmith
Linked PRs
dataclasscode caching #92650