[Python-Dev] Alternative implementation of interning, take 2

M.-A. Lemburg mal@lemburg.com
Fri, 12 Jul 2002 10:24:10 +0200


Tim Peters wrote:
> [Oren Tirosh]
> 
>>...
>>This version, like the previous one, does not support indirect
>>interning of strings.  Is there any evidence that this optimization is
>>still important?  Nothing in the Python distribution itself needs it.
> 
> 
> We've already been thru the last part at length:  indirect interning wasn't
> targeted at the core, so that the core doesn't need it is evidence of no
> more than that Guido's implementation worked as he intended it to in this
> respect.
> 
> It would help if you could get Marc-Andre and /F to pronounce on whether
> their code benefits from it -- they're the most prolific extension authors
> we've got.

Gee, thanks :-)

If you could spell out what exactly you mean by "indirect interning"
that would help.

What I do need and rely on is the fact that the
Python compiler interns all constant strings and identifiers in
Python programs. This makes switching like so:

if a == 'x':
elif a == 'y':
else:

also work like this (only faster):

if a is 'x':
elif a is 'y':
else:

provided that 'a' only uses interned strings.

If that's what you mean by "indirect interning" then I do
need this.

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting:                               http://www.egenix.com/
Python Software:                    http://www.egenix.com/files/python/