3 ms·
I believe this is the example where dataclasses could have supported __slots__ better with a metaclass? Thanks for working on dataclasses :) - as I said, it's
by kzrdude 6y ago
I believe this is the example where dataclasses could have supported __slots__ better with a metaclass?
Thanks for working on dataclasses :) - as I said, it's my #1 new feature in Python.
- ericvsmith 6y agoMaybe that would have worked better with a metaclass. But still, I think not using a metaclass is the more flexible design. Maybe I'll add the "add_slots" behavior into the @dataclass decorator in 3.10, even though it would need to return a new class. At least it could be well documented, and I doubt it's a concern for most people. > Thanks for working on dataclasses :) - as I said, it's my #1 new feature in Python. I'm offended! I also wrote f-strings, but maybe that's not considered new anymore. In any event, you're welcome!
- kzrdude 6y agoMaybe the __slots__ discussion is not really that important - it's just convenience, and the regular old method of adding slots still works. So it's a minor thing. I have diligently converted to f-strings but it doesn't give me new expressibility like I feel dataclasses do, just convenience :)
- imcoconut 6y agofstrings and datclasses changed my life. thank you :)