Skip to content

Commit cb8d471

Browse files
committed
Also do no copy on PyDictProxy_Type compares
1 parent 6933daf commit cb8d471

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Objects/descrobject.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,9 @@ mappingproxy_richcompare(PyObject *self, PyObject *w, int op)
12411241
// for memory optimization. See gh-152405 for the details.
12421242
if (
12431243
PyDict_CheckExact(v->mapping) &&
1244-
!(PyAnyDict_CheckExact(w) || PyODict_CheckExact(w))
1244+
!(PyAnyDict_CheckExact(w) ||
1245+
Py_TYPE(w) == &PyDictProxy_Type ||
1246+
PyODict_CheckExact(w))
12451247
) {
12461248
// So, instead we send a copy:
12471249
PyObject *copy = PyDict_Copy(v->mapping);

0 commit comments

Comments
 (0)