diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-11-22 14:30:38 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-11-22 14:30:38 (GMT) |
commit | bcf4dccfa77df6fd75181e2a7cbfbf2d4b2c6255 (patch) | |
tree | 000475f7e8e7c173eab2743d901f00b3c01b7db0 /Modules/_sre.c | |
parent | e670b2d5c39ce6ac72890e52e9d505f90c33ccba (diff) | |
download | cpython-bcf4dccfa77df6fd75181e2a7cbfbf2d4b2c6255.zip cpython-bcf4dccfa77df6fd75181e2a7cbfbf2d4b2c6255.tar.gz cpython-bcf4dccfa77df6fd75181e2a7cbfbf2d4b2c6255.tar.bz2 |
Issue #28727: Optimize pattern_richcompare() for a==a
A pattern is equal to itself.
Diffstat (limited to 'Modules/_sre.c')
-rw-r--r-- | Modules/_sre.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Modules/_sre.c b/Modules/_sre.c index 1b77416..979e61f 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -2683,6 +2683,12 @@ pattern_richcompare(PyObject *lefto, PyObject *righto, int op) if (Py_TYPE(lefto) != &Pattern_Type || Py_TYPE(righto) != &Pattern_Type) { Py_RETURN_NOTIMPLEMENTED; } + + if (lefto == righto) { + /* a pattern is equal to itself */ + return PyBool_FromLong(op == Py_EQ); + } + left = (PatternObject *)lefto; right = (PatternObject *)righto; |