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

Raymond Hettinger python at rcn.com
Mon May 31 08:50:25 EDT 2004


> > Hmm... it is a high price to pay to add another word (*and* some
extra
> > code at dealloc time!) to every string object when very few apps
need
> > them and strings are about the most common data type.  And since
> > they're immutable, what's the point of having weak refs to strings
in
> > the first place?  (Note that the original poster asked about
> > *subclasses* of strings.)
> 
> Same here. I wouldnot vote to make strings or tuples or any other
> tiny type weak-reffed in the first place.
> Instead I would add the possible support to derived types, via
> the __slot__ mechanism for instance.
> There is a little coding necessary to make the generic code
> handle the case of var-sized objects, but this is doable
> and not very complicated.

Right.  

I think this is all that is needed at this point.  That way, the
granular types stay granular and the added functionality is available
via subclasses if needed.


Raymond




More information about the Python-Dev mailing list