On 20 Dec 2007 19:50:31 -0800, Aahz <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Carl Banks <[EMAIL PROTECTED]> wrote: > >On Dec 18, 4:49 pm, [EMAIL PROTECTED] (Aahz) wrote: > >> In article <[EMAIL PROTECTED]>, > >> Chris Mellon <[EMAIL PROTECTED]> wrote: > >>> > >>>You can reduce the size of new-style classes (inherit from object) by > >>>quite a bit if you use __slots__ to eliminate the class dictionary. > >> > >> You can also reduce your functionality quite a bit by using __slots__. > >> Someday I'll have time to write up a proper page about why you shouldn't > >> use __slots__.... > > > >Shouting absolute commands without full understanding of the situation > >is not going to help anyone. > > Maybe not, but at least it will get people to stop for a bit. >
No, it will just make people stop ignoring you because you give inappropriate advice forbidding reasonable solutions without a rational justification. > >The OP wanted to minimize memory usage, exactly the intended usage of > >slots. Without knowing more about the OP's situation, I don't think > >your or I or Chris Mellon can be sure it's not right for the OP's > >situation. > > The whole point about warning against __slots__ is that you should never > use them unless you are certain they're the best solution. Consider what > happens when the OP wants to subclass this __slots__-using class. Nothing. Subclasses of a class with __slots__ get a dict just like anything else, unless they also define slots. Why do you think you can subclass object to get something you can stick arbitrary attributes on? > Avoiding __slots__ will almost never harm anyone, so I feel completely > comfortable sticking with a blanket warning. > -- Barking out your blanket warning in a thread on *the exact use case slots were implemented to address* just makes you look like a mindless reactionary. Stick to posting your warning in threads where people ask how to stop "other people" from setting attributes on "their" instances. -- http://mail.python.org/mailman/listinfo/python-list