Skip to content

Commit fb78a8a

Browse files
committed
Optimize the common path
1 parent 8ce35c3 commit fb78a8a

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Objects/descrobject.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,10 @@ mappingproxy_richcompare(PyObject *self, PyObject *w, int op)
12341234
{
12351235
if (op == Py_EQ || op == Py_NE) {
12361236
mappingproxyobject *v = (mappingproxyobject *)self;
1237+
// Common path optimization:
1238+
if (PyDict_CheckExact(w)) {
1239+
return PyObject_RichCompare(v->mapping, w, op);
1240+
}
12371241
// We can't expose the `v->mapping` itself, so we create a dict copy:
12381242
// it was possible to mutate `v->mapping` in rich-compare methods.
12391243
// See gh-152405 on the details.

0 commit comments

Comments
 (0)