File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,8 @@ Core and Builtins
3333
3434- Issue #28046: Remove platform-specific directories from sys.path.
3535
36+ - Issue #28071: Add early-out for differencing from an empty set.
37+
3638- Issue #25758: Prevents zipimport from unnecessarily encoding a filename
3739 (patch by Eryk Sun)
3840
Original file line number Diff line number Diff line change @@ -1476,6 +1476,10 @@ PyDoc_STRVAR(isdisjoint_doc,
14761476static int
14771477set_difference_update_internal (PySetObject * so , PyObject * other )
14781478{
1479+ if (PySet_GET_SIZE (so ) == 0 ) {
1480+ return 0 ;
1481+ }
1482+
14791483 if ((PyObject * )so == other )
14801484 return set_clear_internal (so );
14811485
@@ -1550,6 +1554,10 @@ set_difference(PySetObject *so, PyObject *other)
15501554 Py_ssize_t pos = 0 ;
15511555 int rv ;
15521556
1557+ if (PySet_GET_SIZE (so ) == 0 ) {
1558+ return set_copy (so );
1559+ }
1560+
15531561 if (!PyAnySet_Check (other ) && !PyDict_CheckExact (other )) {
15541562 return set_copy_and_difference (so , other );
15551563 }
You can’t perform that action at this time.
0 commit comments