[Python-Dev] Interning string subtype instances

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Feb 14 03:32:24 CET 2007


Martin v. Löwis wrote:
> Greg Ewing schrieb:
> 
 > > The string comparison method knows when both
> > strings are interned
> 
> No, it doesn't - see stringobject.c:string_richcompare.

Well, I'm surprised and confused.

It's certainly possible to tell very easily whether
a string is interned -- there's a PyString_CHECK_INTERNED
macro that tests a field in the string object header.
But, I can't find anywhere that it's used in the core,
apart from the interning code itself and the string
alloc/dealloc code.

Can anyone shed any light on this? It seems to me that
by not using this information, only half the benefit of
interning is being achieved.

--
Greg


More information about the Python-Dev mailing list