Skip to content

Commit

Permalink
bpo-43464: Optimize set.intersection() for non-set arguments (GH-31316)
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka committed Apr 6, 2022
1 parent 50872db commit 31cd25f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
@@ -0,0 +1 @@
Optimize :meth:`set.intersection` for non-set arguments.
4 changes: 4 additions & 0 deletions Objects/setobject.c
Expand Up @@ -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);
}
Expand Down

0 comments on commit 31cd25f

Please sign in to comment.