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

Guido van Rossum guido@python.org
Fri, 07 Jun 2002 00:02:44 -0400


> > 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.

OK, let's do this.

> > 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.

So let's expose a function that cleans out unused strings from the
interned dict.  Long-running apps can decide when to call this.

--Guido van Rossum (home page: http://www.python.org/~guido/)