mirror of
https://github.com/python/cpython.git
synced 2025-01-24 10:04:09 +08:00
Issue #28071: Add early-out for differencing from an empty set.
This commit is contained in:
parent
34b74fffb3
commit
4103e4dfbc
@ -33,6 +33,8 @@ Core and Builtins
|
||||
|
||||
- Issue #28046: Remove platform-specific directories from sys.path.
|
||||
|
||||
- Issue #28071: Add early-out for differencing from an empty set.
|
||||
|
||||
- Issue #25758: Prevents zipimport from unnecessarily encoding a filename
|
||||
(patch by Eryk Sun)
|
||||
|
||||
|
@ -1476,6 +1476,10 @@ PyDoc_STRVAR(isdisjoint_doc,
|
||||
static int
|
||||
set_difference_update_internal(PySetObject *so, PyObject *other)
|
||||
{
|
||||
if (PySet_GET_SIZE(so) == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((PyObject *)so == other)
|
||||
return set_clear_internal(so);
|
||||
|
||||
@ -1550,6 +1554,10 @@ set_difference(PySetObject *so, PyObject *other)
|
||||
Py_ssize_t pos = 0;
|
||||
int rv;
|
||||
|
||||
if (PySet_GET_SIZE(so) == 0) {
|
||||
return set_copy(so);
|
||||
}
|
||||
|
||||
if (!PyAnySet_Check(other) && !PyDict_CheckExact(other)) {
|
||||
return set_copy_and_difference(so, other);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user