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

Guido van Rossum guido@python.org
Fri, 07 Jun 2002 09:19:51 -0400


> > So let's expose a function that cleans out unused strings from the
> > interned dict.  Long-running apps can decide when to call this.
> 
> Would it do any harm to call this automatically from
> the garbage collector?

That's what I initially proposed -- do it in the last-generation GC
pass, which runs every million object allocations or so.  But since
this is potentially expensive (running through a large dict),
long-running processes might want to control when it runs.

> I suppose it should be exposed as well, in case you
> want it but have GC turned off -- but in the normal
> case you shouldn't have to do anything special to
> get it.

It's a pure slowdown for more programs, even long-running programs
(one could say *especially* for long-running programs, since
short-running programs won't get to the last generation GC pass).

Only long-running (24x7) servers that execute some kind of
(pseudo-)code submitted by clients are vulnerable to the
interned-dict-bloat problem.  Such programs are full of hacks to limit
memory bloat already, so this would be yet another trick for them to
deploy.

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