"Ìð¹Ï" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | > # an efficient 'Pair' class holding two objects | > class Pair(object): | > __slots__ = 'first', 'second' | > | > Instances of Pair take up even less room that 2-element tuples | > because they don't carry the size information in the object. | > | > Now, if the object class carried a dict with it, it would be | > impossible to create a class like 'Pair'. | > | Really interesting. When the tuple ('first', 'second') is assigning to | __slot__, a special operation is done which makes __slot__ pointing | to a magic structure rather than a normal tuple. Am I right?
Try it. Run the code and print P.__slots__. <pause> Class statements are implemented by calling the metaclass 'type' with 3 args. Type.__new__ uses the information in those args. If the namespace arg has a __slots__ member, it does something special based on the strings in the tuple, but it leaves the tuple alone.
-- http://mail.python.org/mailman/listinfo/python-list