[Python-Dev] d.get_key(key) -> key?

Martin v. Loewis martin@v.loewis.de
06 Jun 2002 22:16:04 +0200


Guido van Rossum <guido@python.org> writes:

> To solve this, we would have to make the ob_sinterned slot count as a
> reference to the interned string.  But then string_dealloc would be
> complicated (it would have to call Py_XDECREF(op->ob_sinterned)),
> possibly slowing things down.
> 
> Is this worth it?  

That (latter) change seem "right" regardless of whether interned
strings are ever released.

> The fear for unbounded growth of the interned strings table is
> pretty common amongst authors of serious long-running programs.

I think it is. Unbound growth of interned strings is precisely the
reason why the XML libraries repeatedly came up with their own
interning dictionaries, which only persist for the lifetime of parsing
the document, since the next document may want to intern entirely
different things. This is the reason that the intern() function is bad
to use for most applications.

Regards,
Martin