question: usage of __slots__

Michael Hudson mwh at python.net
Tue Oct 14 08:50:45 EDT 2003


"Rainer Deyke" <rainerd at eldwood.com> writes:

> Alexander Schmolck wrote:
> > __slots__ are a premature optimization and best avoided.
> 
> __slots__ is also an error-catching mechanism.

Yes, but it's intent is as a memory saving optimization.  Really.  In:

    http://mail.python.org/pipermail/python-dev/2003-August/037542.html

Guido says:

    __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.

Cheers,
mwh

-- 
  I'm sorry, was my bias showing again? :-)
                                      -- William Tanksley, 13 May 2000




More information about the Python-list mailing list