[Python-Dev] Why aren't more things weak referencable

Phillip J. Eby pje at telecommunity.com
Sun May 30 01:34:46 EDT 2004


At 01:24 AM 5/30/04 -0400, Bob Ippolito wrote:
>On May 29, 2004, at 1:06 PM, Raymond Hettinger wrote:
>
>>Instances of classes inheriting from str, tuple, etc cannot be weakly 
>>referenced.  Does anyone know the reason for this?
>
>They can not accept non-empty __slots__ either, which is probably closer 
>to the source of the problem.  I have no idea what the reason is.  I 
>imagine it's something to do with optimization, and/or because they are 
>immutable.

More likely, because they are variably-sized, and their variably-sized 
portions are at fixed offsets.  (OTOH, I don't see why their subclasses can 
still have a __dict__ slot, then...)




More information about the Python-Dev mailing list