Skip to content

Commit 2e8f721

Browse files
authored
gh-90861: Memory optimization for set.issubset (gh-92799)
1 parent 9f68dab commit 2e8f721

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Objects/setobject.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,13 +1735,13 @@ set_issubset(PySetObject *so, PyObject *other)
17351735
int rv;
17361736

17371737
if (!PyAnySet_Check(other)) {
1738-
PyObject *tmp, *result;
1739-
tmp = make_new_set(&PySet_Type, other);
1740-
if (tmp == NULL)
1738+
PyObject *tmp = set_intersection(so, other);
1739+
if (tmp == NULL) {
17411740
return NULL;
1742-
result = set_issubset(so, tmp);
1741+
}
1742+
int result = (PySet_GET_SIZE(tmp) == PySet_GET_SIZE(so));
17431743
Py_DECREF(tmp);
1744-
return result;
1744+
return PyBool_FromLong(result);
17451745
}
17461746
if (PySet_GET_SIZE(so) > PySet_GET_SIZE(other))
17471747
Py_RETURN_FALSE;

0 commit comments

Comments
 (0)