question: usage of __slots__

Rainer Deyke rainerd at eldwood.com
Mon Oct 13 18:26:50 EDT 2003


Alexander Schmolck wrote:
> __slots__ are a premature optimization and best avoided.

__slots__ is also an error-catching mechanism.

class A(object):
  __slots__ = ['spam']
  pass

A().spaam = 0 # Caught at assign time.


-- 
Rainer Deyke - rainerd at eldwood.com - http://eldwood.com






More information about the Python-list mailing list