[Python-Dev] Alternative implementation of interning

Tim Peters tim@zope.com
Sun, 18 Aug 2002 23:15:08 -0400


[Oren Tirosh]
> ...
> The problem is in C extension modules. In C there is an incentive to rely
> on the immortality of interned strings because it makes the code simpler.

Are you sure about that?  I haven't seen it.

> There was an example of this in the Mac import code.

Code *inside* the core can play any dirty tricks it likes, because we
guarantee to keep it working as things change across releases.  But, AFAICT,
we have no evidence that anything outside the core abuses this stuff.

> PyString_InternInPlace should probably create immortal interned strings
> for backward compatibility (and deprecated, of course)

I still doubt it matters to anything outside the core.

> Maybe PyString_Intern should be renamed to PyString_InternReference to
> make it more obvious that it modifies the pointer "in place".

You're talking about a function that doesn't exist now, right (I don't
recognize the name PyString_Intern, and neither it nor
PyString_InternReference scream anything obvious to me)?