3 ms·
I don't think you're likely to see zero overhead decorators any more than "zero overhead software" in general. Take dataclasses: it adds a bunch of synthesized
by ericvsmith 4y ago
I don't think you're likely to see zero overhead decorators any more than "zero overhead software" in general.
Take dataclasses: it adds a bunch of synthesized methods to a class, and needs to use "exec" to create them. How could that be zero overhead?
To help with this, I've proposed moving knowledge of dataclasses into the Python compiler, but even I don't think it's a great idea. For example, it would leave attrs in a disadvantaged position, and I don't want to do that.
Another option would be to move dataclasses before the code generator. Syntactic macros are one way to do that. Then there really would be zero overhead when loading the cached .pyc files. That's their appeal to me. Of course there are lots of other things that could be done with syntactic macros, which is both good and bad.