Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 86980:77bebcf5c4cf
Issue #19512: add _PyUnicode_CompareWithId() function
_PyUnicode_CompareWithId() is faster than PyUnicode_CompareWithASCIIString()
when both strings are equal and interned.
Add also _PyId_builtins identifier for "builtins" common string.
| author | Victor Stinner <victor.stinner@gmail.com> |
|---|---|
| date | Thu, 07 Nov 2013 00:46:04 +0100 |
| parents | e9a865620788 |
| children | 7c71d2f97196 |
comparison
equal
deleted
inserted
replaced
| 86979:e9a865620788 | 86980:77bebcf5c4cf |
|---|---|
| 35 #define PATH_MAX MAXPATHLEN | 35 #define PATH_MAX MAXPATHLEN |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 /* Common identifiers */ | 38 /* Common identifiers */ |
| 39 _Py_Identifier _PyId_argv = _Py_static_string_init("argv"); | 39 _Py_Identifier _PyId_argv = _Py_static_string_init("argv"); |
| 40 _Py_Identifier _PyId_builtins = _Py_static_string_init("builtins"); | |
| 40 _Py_Identifier _PyId_path = _Py_static_string_init("path"); | 41 _Py_Identifier _PyId_path = _Py_static_string_init("path"); |
| 41 _Py_Identifier _PyId_stdin = _Py_static_string_init("stdin"); | 42 _Py_Identifier _PyId_stdin = _Py_static_string_init("stdin"); |
| 42 _Py_Identifier _PyId_stdout = _Py_static_string_init("stdout"); | 43 _Py_Identifier _PyId_stdout = _Py_static_string_init("stdout"); |
| 43 _Py_Identifier _PyId_stderr = _Py_static_string_init("stderr"); | 44 _Py_Identifier _PyId_stderr = _Py_static_string_init("stderr"); |
| 44 | 45 |
| 1926 { | 1927 { |
| 1927 Py_XDECREF(moduleName); | 1928 Py_XDECREF(moduleName); |
| 1928 err = PyFile_WriteString("<unknown>", f); | 1929 err = PyFile_WriteString("<unknown>", f); |
| 1929 } | 1930 } |
| 1930 else { | 1931 else { |
| 1931 if (PyUnicode_CompareWithASCIIString(moduleName, "builtins") != 0) | 1932 if (_PyUnicode_CompareWithId(moduleName, &_PyId_builtins) != 0) |
| 1932 { | 1933 { |
| 1933 err = PyFile_WriteObject(moduleName, f, Py_PRINT_RAW); | 1934 err = PyFile_WriteObject(moduleName, f, Py_PRINT_RAW); |
| 1934 err += PyFile_WriteString(".", f); | 1935 err += PyFile_WriteString(".", f); |
| 1935 } | 1936 } |
| 1936 Py_DECREF(moduleName); | 1937 Py_DECREF(moduleName); |
