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

Aahz aahz at pythoncraft.com
Tue Jul 25 12:17:51 EDT 2006


In article <1153843248.761424.246730 at i3g2000cwc.googlegroups.com>,
 <bearophileHUGS at lycos.com> wrote:
>Aahz, citing Guido:
>>
>>__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
>
>I think I have used __slots__ just one time. Can you tell me some of of
>such bad side effects?

The main one is that inheritance becomes difficult to nearly-impossible.
-- 
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