__slots__ and multiple inheritance

Carl Banks imbosol at vt.edu
Sat Dec 14 20:19:40 EST 2002


Bengt Richter wrote:
> ISTM __xxx__ primarily serves as an object definition metalanguage (1).
> I.e., we use it to compose objects with standard behaviours and attributes
> used implicitly in higher level constructs.  Perhaps moving towards using
> __xxx__ purely for that primary purpose would be a good thing?
> 
> 1. standard primitive object attributes
> 2. compiler hints/directives
>    2.1 allocation-related
>    2.2 metaclass linkage
> 3. import/loader hints/directives
> 4. ?

Personally, I don't have any problem with __xxx__ meaning simply "this
symbol has extra or different meaning given to it by the language."
Trying to codify and restrict what the meanings might be is just being
too anal retentive about it.


> I.e. __slots__ seems effectively an optimization hint (actually
> directive, I guess).  Or is the restriction above a design intent
> rather than a necessary side effect?

No, it's definitely a necessary side effect.  If they could have done
it without the MI restriction, they would have.  And it's definitely
not an optimization.  Its purpose is to help avoid misspelling bugs.

Personally, I never use slots, because I've never found misspelling
bugs to be much of a problem.


-- 
CARL BANKS



More information about the Python-list mailing list