Don't use __slots__! (was Re: dicts vs classes)

Aahz aahz at pythoncraft.com
Fri Jul 28 16:03:11 EDT 2006


In article <ea5jd5$ia8$1 at reader2.panix.com>, Roy Smith <roy at panix.com> wrote:
>>Guido sez:
>>
>>     __slots__ is a terrible hack with nasty, hard-to-fathom side
>>     effects that should only be used by programmers at grandmaster and
>>     wizard levels. Unfortunately it has gained an enormous undeserved
>>     popularity amongst the novices and apprentices, who should know
>>     better than to use this magic incantation casually.
>
>But, if they are novices, why should they be expected to know better?
>
>I just re-read http://docs.python.org/ref/slots.html#l2h-217 and don't
>see anyplace where it says, "Warning: for use by wizards only".

Unfortunately, the Python docs are currently suboptimal when it comes to
new-style classes.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it."  --Brian W. Kernighan



More information about the Python-list mailing list