[Python-Dev] Interning string subtype instances (original) (raw)
"Martin v. Löwis" martin at v.loewis.de
Wed Feb 14 09:08:29 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 schrieb:
It's certainly possible to tell very easily whether a string is interned -- there's a PyStringCHECKINTERNED 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.
You seem to assume that checking this property would improve performance. I find that questionable; as always with performance and optimization, one cannot know until it has been benchmarked.
My guess is that
- the cases you want to cover are comparably infrequent (compared to the total number of richcompare invocations)
- checking the additional field always may cause a performance loss, not a performance gain, because of the additional tests.
If you want to sure, you need to make some measurements (e.g: what is the percentage of EQ and NE invocations, in how many cases are both strings interned, and in what percentage of these cases are they not the same string).
Regards, Martin
- Previous message: [Python-Dev] Interning string subtype instances
- Next message: [Python-Dev] Interning string subtype instances
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]