<div dir="auto"><div><div class="gmail_extra"><div class="gmail_quote">On Dec 7, 2017 12:49, "Eric V. Smith" <<a href="mailto:eric@trueblade.com">eric@trueblade.com</a>> wrote:<blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The reason I didn't include it (as @dataclass(slots=True)) is because it has to return a new class, and the rest of the dataclass features just modifies the given class in place. I wanted to maintain that conceptual simplicity. But this might be a reason to abandon that. For what it's worth, attrs does have an @attr.s(slots=True) that returns a new class with __slots__ set.</blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">They actually switched to always returning a new class, regardless of whether slots is set:</div><div dir="auto"><br></div><div dir="auto"><a href="https://github.com/python-attrs/attrs/pull/260">https://github.com/python-attrs/attrs/pull/260</a><br></div><div dir="auto"><br></div><div dir="auto">You'd have to ask Hynek to get the full rationale, but I believe it was both for consistency with slot classes, and for consistency with regular class definition. For example, type.__new__ actually does different things depending on whether it sees an __eq__ method, so adding a method after the fact led to weird bugs with hashing. That class of bug goes away if you always set up the autogenerated methods and then call type.__new__.</div><div dir="auto"><br></div><div dir="auto"> -n</div></div>