Raymond Hettinger <rhettin...@users.sourceforge.net> added the comment:
Daniel, do you have time to work on this one? If so, go ahead an make setobject.c accept any instance of collections.Set and make the corresponding change to the ABCs: def __or__(self, other): if not isinstance(other, Set): return NotImplemented chain = (e for s in (self, other) for e in s) return self._from_iterable(chain) The code in the attached prelim.patch has working C code isinstance(x, collections.Set), but the rest of the patch that applies is has not been tested. It needs to be applied very carefully and thoughtfully because: * internally, the self and other can get swapped on a binary call * we can't make *any* assumptions about "other" (that duplicates have actually been eliminated or the the elements are even hashable). The most reliable thing to do for the case where PyAnySet(obj) is False but isinstance(obj, collections.Set) is true is to call the named method such as s.union(other) instead of continuing with s.__or__ which was designed only with real sets in mind. ---------- assignee: rhettinger -> stutzbach _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue8743> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com