[Python-checkins] gh-90861: Memory optimization for set.issubset (gh-92799)

corona10 webhook-mailer at python.org
Sat May 14 04:58:54 EDT 2022


https://github.com/python/cpython/commit/2e8f721c0f275d9d7c018b4a2a66f053cf34bb36
commit: 2e8f721c0f275d9d7c018b4a2a66f053cf34bb36
branch: main
author: Dong-hee Na <donghee.na at python.org>
committer: corona10 <donghee.na92 at gmail.com>
date: 2022-05-14T17:58:19+09:00
summary:

gh-90861: Memory optimization for set.issubset (gh-92799)

files:
M Objects/setobject.c

diff --git a/Objects/setobject.c b/Objects/setobject.c
index 4b6a8b8dfb679..dd55a943010ab 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -1735,13 +1735,13 @@ set_issubset(PySetObject *so, PyObject *other)
     int rv;
 
     if (!PyAnySet_Check(other)) {
-        PyObject *tmp, *result;
-        tmp = make_new_set(&PySet_Type, other);
-        if (tmp == NULL)
+        PyObject *tmp = set_intersection(so, other);
+        if (tmp == NULL) {
             return NULL;
-        result = set_issubset(so, tmp);
+        }
+        int result = (PySet_GET_SIZE(tmp) == PySet_GET_SIZE(so));
         Py_DECREF(tmp);
-        return result;
+        return PyBool_FromLong(result);
     }
     if (PySet_GET_SIZE(so) > PySet_GET_SIZE(other))
         Py_RETURN_FALSE;



More information about the Python-checkins mailing list