mirror of
https://github.com/python/cpython.git
synced 2025-07-12 05:45:15 +00:00
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.
This commit is contained in:
parent
937114f704
commit
ad14ccd047
6 changed files with 32 additions and 15 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue