[Python-Dev] Re: Alternative implementation of string interning

Tim Peters tim.one@comcast.net
Fri, 05 Jul 2002 19:21:12 -0400


[M.-A. Lemburg]
> Has anybody ever checked how many such strings live in the
> intern dict with ref count 1 in real life apps ?
>
> E.g. say you have Zope running on a standard web-site
> for 2 days -- how many such strings do you find in the
> interned dict ?

I don't know.  Jim Fulton has raised it as a Zope issue in the past, and my
recollection is that each time this comes up we go through a dance like:

    OK, we'll turn off interning in that path.
    ...
    Oops!  It looks like we already did!
    ...
    Oops!  I guess we didn't on *that* path.
    ...
    *Which* paths does Zope use again?
    ...
    Ah, OK, no, we already turned off interning in those paths.
    ...
    Or at least we did in Python version i.j.k.  *Which* versions
    are we worried about again?
    ...
    Does anyone remember which paths we're worried about?
    ...

It fizzles out then due to terminal boredom <wink>.

> Speaking for myself, I would have a problem with removing
> automatic interning of constant strings in Python source
> code

I don't believe anyone has suggested doing so.  Note that we don't
automatically intern all constant strings in Python source, we only intern
constant strings that "look like" identifiers.  This is from fear of the
immortality of interned strings.

> since I rely on that "feature" for fast switching
> on values (if..elif..elif.......else). Since code objects
> usually don't go away while the interpreter is running,
> these would not be affected by the proposed strategy.