On Fri, Sep 27, 2019, at 12:48, Andrew Barnert via Python-ideas wrote:
> or get rid of the guarantee that @dataclass returns your
> class with extra dunders.
Why is dataclass a decorator instead of a metaclass (or, as below,
pseudo-metaclass) anyway? Is it just that the decorator syntax looks nicer? If
it were a metaclass, it could add __slots__ before constructing the class.
def slot_dataclass(name, bases, dct):
dct['__slots__'] = dct['__annotations__'].keys()
return dataclasses.dataclass(type(name, bases, dct))
If the problem is that the metaclass syntax is ugly, maybe we need a
nicer-looking metaclass syntax, e.g. "class MyClass(bases) as slot_dataclass:"
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/7NRCZMDHKNONRPVGK6H6MWSB4PVUNU6T/
Code of Conduct: http://python.org/psf/codeofconduct/