[Python-Dev] Interning string subtype instances (original) (raw)
Larry Hastings larry at hastings.org
Wed Feb 14 20:27:59 CET 2007
- Previous message: [Python-Dev] Interning string subtype instances
- Next message: [Python-Dev] Interning string subtype instances
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Greg Ewing wrote:
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. If I understand your question correctly, you're saying "why doesn't string comparison take advantage of interned strings?" If so, the answer is "it does". Examine string_richcompare() in stringobject.c, and PyUnicode_compare() in unicodeobject.c. Both functions compare the pointers of the two objects in case they are literally the same object, and if so skip all the expensive comparison code. Interned strings which have the same value are likely to be (are guaranteed to be?) the same object. And there you are.
If that's not the question you are asking, I'll be quiet, 'cause it seems like other people understand what you're talking about.
Cheers,
/larry/
- Previous message: [Python-Dev] Interning string subtype instances
- Next message: [Python-Dev] Interning string subtype instances
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]