diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-11-06 23:46:04 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-11-06 23:46:04 (GMT) |
commit | ad14ccd047022d09f486d2359a342ffc5e676e5a (patch) | |
tree | 8ddf45c544c55f71d3aa1a877bd6b6d136d972f9 /Python | |
parent | 937114f7043d6a52172a34fe04febcc5ed0eaed9 (diff) | |
download | cpython-ad14ccd047022d09f486d2359a342ffc5e676e5a.zip cpython-ad14ccd047022d09f486d2359a342ffc5e676e5a.tar.gz cpython-ad14ccd047022d09f486d2359a342ffc5e676e5a.tar.bz2 |
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.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/errors.c | 2 | ||||
-rw-r--r-- | Python/pythonrun.c | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/Python/errors.c b/Python/errors.c index b92911a..93e4724 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -878,7 +878,7 @@ PyErr_WriteUnraisable(PyObject *obj) goto done; } else { - if (PyUnicode_CompareWithASCIIString(moduleName, "builtins") != 0) { + if (_PyUnicode_CompareWithId(moduleName, &_PyId_builtins) != 0) { if (PyFile_WriteObject(moduleName, f, Py_PRINT_RAW) < 0) goto done; if (PyFile_WriteString(".", f) < 0) diff --git a/Python/pythonrun.c b/Python/pythonrun.c index e0c8638..be41de6 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -37,6 +37,7 @@ /* Common identifiers */ _Py_Identifier _PyId_argv = _Py_static_string_init("argv"); +_Py_Identifier _PyId_builtins = _Py_static_string_init("builtins"); _Py_Identifier _PyId_path = _Py_static_string_init("path"); _Py_Identifier _PyId_stdin = _Py_static_string_init("stdin"); _Py_Identifier _PyId_stdout = _Py_static_string_init("stdout"); @@ -1928,7 +1929,7 @@ print_exception(PyObject *f, PyObject *value) err = PyFile_WriteString("<unknown>", f); } else { - if (PyUnicode_CompareWithASCIIString(moduleName, "builtins") != 0) + if (_PyUnicode_CompareWithId(moduleName, &_PyId_builtins) != 0) { err = PyFile_WriteObject(moduleName, f, Py_PRINT_RAW); err += PyFile_WriteString(".", f); |