]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-90861: Memory optimization for set.issubset (gh-92799)
authorDong-hee Na <donghee.na@python.org>
Sat, 14 May 2022 08:58:19 +0000 (17:58 +0900)
committerGitHub <noreply@github.com>
Sat, 14 May 2022 08:58:19 +0000 (17:58 +0900)
Objects/setobject.c

index 4b6a8b8dfb679d9919c03ffc8468a60c77eaff7a..dd55a943010ab801add9d117f8ff7922dbcb3d90 100644 (file)
@@ -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;