Questions on __slots__

Adam Tauno Williams awilliam at whitemice.org
Sat May 19 09:39:19 EDT 2012


On Fri, 2012-05-18 at 09:53 -0700, Charles Hixson wrote: 
> Does __slots__ make access to variables more efficient?

Absolutely, yes.

> If one uses property() to create a few read-only pseudo-variables, does 
> that negate the efficiency advantages of using __slots__?
> (Somehow I feel the documentation needs a bit of improvement.)

If you are tempted to use property, setattr, etc... then do not use
__slots__.  __slots__ should really only be used for Fly Weight pattern
type work, or at least for objects with a limited scope and will not be
inherited from.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-list/attachments/20120519/f0625d86/attachment.sig>


More information about the Python-list mailing list