I decided to take a look at this yesterday.
I’ve gotten a very rough version of code-caching working for dataclasses
(all tests are passing). As a preliminary benchmark, the dataclasses
test suite is running about twice as quickly… I haven’t timed @dataclass
generation time specifically yet, but I suspect that it’s even better than that (the tests are doing a lot more than just generating dataclasses, and the generated code hasn’t changed at all).
Something like 95% of generated methods don’t actually go through exec
, but just use code.replace
to patch a few names and constants. I also expect that memory use has improved as well. I’ll be doing more cleanup and experiments on my branch today.