Inheritable Slots Metaclass

John Nagle nagle at animats.com
Thu May 27 00:19:46 EDT 2010


Rebel Lion wrote:
>> I'd be ok with a metatype in the standard library that makes slots
>> more transparent, but since slots are intended as an optimization, it
>> doesn't really need (and might be detrimental to have) transparency
>> for ordinary objects.
>>
> 
> But why there is __slots__ if it's not indeed needed. we should make
> it more usable instead of a hack, which it now looks like.
> 
>> However, Aahz will be by shortly to tell you never to use slots.

     I'd argue that "slotting" of classes should be automatic, unless a class
1) defines "__setattr__" or 2) performs an operation which visibly
creates a class attribute, like "self[foo] = ...".  This would handle
the common use cases.  Only classes to which attributes are added from
outside the class would be affected.  And really, if you're going to do
that, you should subclass.

					John Nagle



More information about the Python-list mailing list