Index: Objects/setobject.c =================================================================== --- Objects/setobject.c (revision 81048) +++ Objects/setobject.c (working copy) @@ -1612,7 +1612,10 @@ static PyObject * set_isub(PySetObject *so, PyObject *other) { - if (!PyAnySet_Check(other)) { + if (!PyAnySet_Check(other) || + /* Fall back to s = s - o if len(s) < len(o) to + avoid interation over a large set. */ + PySet_GET_SIZE(so) < PySet_GET_SIZE(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; }