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:
Victor Stinner 2013-11-07 00:46:04 +01:00
parent 937114f704
commit ad14ccd047
6 changed files with 32 additions and 15 deletions

View file

@ -10565,6 +10565,15 @@ PyUnicode_Compare(PyObject *left, PyObject *right)
return -1;
}
int
_PyUnicode_CompareWithId(PyObject *left, _Py_Identifier *right)
{
PyObject *right_str = _PyUnicode_FromId(right); /* borrowed */
if (right_str == NULL)
return -1;
return PyUnicode_Compare(left, right_str);
}
int
PyUnicode_CompareWithASCIIString(PyObject* uni, const char* str)
{