bpo-43464: Optimize set.intersection() for non-set arguments (GH-31316)

This commit is contained in:
Serhiy Storchaka 2022-04-06 19:56:28 +03:00 committed by GitHub
parent 50872dbadc
commit 31cd25f4e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View file

@ -1240,6 +1240,10 @@ set_intersection(PySetObject *so, PyObject *other)
if (rv) {
if (set_add_entry(result, key, hash))
goto error;
if (PySet_GET_SIZE(result) >= PySet_GET_SIZE(so)) {
Py_DECREF(key);
break;
}
}
Py_DECREF(key);
}