News for hackers. Stuff that matters.
Re:Applying Mypy to real-world projects by duckerude on Wednesday February 12, 2020 @04:28AM (#22307318)
> Especially with `slots=True`, dataclasses can take less resources.

`slots=True` doesn't exist, though there's an experimental implementation at https://github.com/ericvsmith/dataclasses/blob/master/datacl... .

The main issue is that slots have to exist at class definition, and @dataclass takes an already defined class, so you'd have to create a clone of the class, which is nasty.

On top of that you can't always add __slots__ manually, because it conflicts with default field values (and field()s). __slots__ wants to add a descriptor as a class attribute but it can't do that if the default value is already an attribute.

Re:Applying Mypy to real-world projects by calpaterson on Wednesday February 12, 2020 @06:46AM (#22308023)
The GP is probably referring to the attrs library, which is another (older) way of creating dataclasses than the stdlib way. It has an easy way to create slotted dataclasses.

http://www.attrs.org/en/stable/examples.html#slots