[Python-Dev] Identifier API (original) (raw)
Victor Stinner victor.stinner at haypocalc.com
Thu Oct 13 03:34:00 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 00:44:33, Victor Stinner a écrit :
Le samedi 8 octobre 2011 16:54:06, Martin v. Löwis a écrit : > In benchmarking PEP 393, I noticed that many UTF-8 decode > calls originate from C code with static strings, in particular > PyObjectCallMethod. Many of such calls already have been optimized > to cache a string object, however, PyObjectCallMethod remains > unoptimized since it requires a char*.
Because all identifiers are ASCII (in the C code base), another idea is to use a structure similar to PyASCIIObject but with an additional pointer to the constant char* string:
Oh, I realized that Martin did already commit its PyIdentifier API, it's maybe too late :-)
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 :-)
Victor
- Previous message: [Python-Dev] Identifier API
- Next message: [Python-Dev] Identifier API
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]