[Python-Dev] Identifier API (original) (raw)
Victor Stinner victor.stinner at haypocalc.com
Fri Oct 14 00:30:51 CEST 2011
- Previous message: [Python-Dev] Identifier API
- Next message: [Python-Dev] Identifier API
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Le jeudi 13 octobre 2011 03:34:00, Victor Stinner a écrit :
> We would need a new format for PyBuildValue, e.g. 'a' for ASCII string. > Later we can add new functions like PyDictGetASCII().
The main difference between my new "const ASCII" string idea and PyIdentifier is the lifetime of objects. Using "const ASCII" strings, the strings are destroyed quickly (to not waste memory), whereas PyIdentifiers are intern strings and so they are only destroyed at Python exit. I don't know if "const ASCII" strings solve a real issue. I implemented my idea. I will do some benchmarks to check if it's useful or not :-)
Ok, I did some tests: it is slower with my PyConstASCIIObject. I don't understand why, but it means that the idea is not interesting because the code is not faster. It is also difficult to ensure that the string is "constant" (test the scope of the string).
At least, I found a nice GCC function: __builtin_constant_p(str) can be used to ensure that the string is constant (e.g. "abc" vs char*).
Victor
- Previous message: [Python-Dev] Identifier API
- Next message: [Python-Dev] Identifier API
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]