mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +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
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue