[Python-Dev] Why aren't more things weak referencable
Christian Tismer
tismer at stackless.com
Mon May 31 19:49:34 EDT 2004
Guido van Rossum wrote:
>>For strings at least, perhaps it is time to bite the bullet and
>>include weak reference support directly. Weak reference support ups
>>the per string memory overhead from five words (ob_type, ob_refcnt,
>>ob_size, ob_shash, ob_sstate) to six. The whole concept of weak
>>dictionaries is much more useful when strings can be used as keys
>>and/or values.
>
>
> 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.
This may be really needed or not. if we can create the rule
"every derived type *can* have weak-refs", this is simpler
to memorize than "well, most can, some cannot".
cheers -- chris
--
Christian Tismer :^) <mailto:tismer at stackless.com>
Mission Impossible 5oftware : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a : *Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34 home +49 30 802 86 56 mobile +49 173 24 18 776
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? http://www.stackless.com/
More information about the Python-Dev
mailing list