diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-11-07 00:46:04 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-11-07 00:46:04 +0100 |
commit | ad14ccd047022d09f486d2359a342ffc5e676e5a (patch) | |
tree | 8ddf45c544c55f71d3aa1a877bd6b6d136d972f9 /Objects/unicodeobject.c | |
parent | 937114f7043d6a52172a34fe04febcc5ed0eaed9 (diff) | |
download | cpython-git-ad14ccd047022d09f486d2359a342ffc5e676e5a.tar.gz |
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 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 574b57a259..4ae73771f2 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -10566,6 +10566,15 @@ PyUnicode_Compare(PyObject *left, PyObject *right) } 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) { Py_ssize_t i; |