[Python-ideas] Providing a guarantee that instances of user-defined classes have distinct identities

Simon Sapin simon.sapin at kozea.fr
Thu Apr 19 15:31:02 CEST 2012

Le 19/04/2012 14:58, Mike Meyer a écrit :
> On Thu, 19 Apr 2012 11:35:13 +0100
> Sven Marnach<sven at marnach.net>  wrote:
>> >  It wouldn't be completely unthinkable that a Python implementation
>> >  chooses to extend this behaviour to immutable subclasses of immutable
>> >  types.  I don't think there is any reason to disallow such an
>> >  implementation either.
> How would the implementation determine that the subclass was
> immutable?

When all classes in the MRO except 'object' have an empty __slots__?

(object behaves just as if it had an empty __slots__, but accessing 
object.__slots__ raises an AttributeError.)

Simon Sapin

More information about the Python-ideas mailing list