Don't use __slots__ (was Re: Problem of Readability of Python)

Aahz aahz at pythoncraft.com
Mon Oct 15 17:40:34 CEST 2007


In article <ocudnf2qE6P46JfanZ2dnUVZ_h-vnZ2d at comcast.com>,
Steven Bethard  <steven.bethard at gmail.com> wrote:
>Aahz wrote:
>> In article <2tqdncU0D6K8v5TanZ2dnUVZ_hGdnZ2d at comcast.com>,
>> Steven Bethard  <steven.bethard at gmail.com> wrote:
>>>
>>> You can use __slots__  [...]
>> 
>> Aaaugh!  Don't use __slots__!
>> 
>> Seriously, __slots__ are for wizards writing applications with huuuge
>> numbers of object instances (like, millions of instances).
>
>You clipped me saying that __slots__ are for performance tweaks:
>
>     You can use __slots__ to make objects consume less memory and have
>     slightly better attribute-access performance. Classes for objects
>     that need such performance tweaks should start like...
>
>I fully agree that __slots__ are for applications with huge numbers of 
>instances. But if you have that situation, you really do want to be 
>using __slots__.

Well, then, just make sure to put big honking warnings up whenever you
mention __slots__.  ;-)
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

The best way to get information on Usenet is not to ask a question, but
to post the wrong information.



More information about the Python-list mailing list