[issue9212] dict_keys purports to implement the Set ABC, but is missing the isdisjoint method
Daniel Stutzbach
report at bugs.python.org
Fri Aug 20 23:35:27 CEST 2010
Daniel Stutzbach <daniel at stutzbachenterprises.com> added the comment:
Thank you for the patch.
We should only iterate over the shorter set if the longer set is really a set and not just a sequence. PySequence_Contains may take O(n) time on a list, making the algorithm an expensive O(n**2) overall. I note that set_isdisjoint doesn't try to examine the lengths.
Also, since PyIter_Next returns NULL to indicate the end of the iteration OR to indicate an exception, the end of the function should look like this:
Py_DECREF(it);
if (PyErr_Occurred())
return NULL;
Py_RETURN_TRUE;
Other than those two issues, the patch looks good to me.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9212>
_______________________________________
More information about the Python-bugs-list
mailing list