On 05/19/2012 06:39 AM, Adam Tauno Williams wrote:
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.
Thank you. What I really wanted was a "named list", sort of like a
"named tuple", only modifiable, but since the only way to do it was to
create a class, I started thinking of reasonable operations for it to
perform (data hiding, etc.) Sounds like I should go back to the "named
list" idea.
--
Charles Hixson
--
http://mail.python.org/mailman/listinfo/python-list