[Python-ideas] Implement __add__ for set and frozenset

Raymond Hettinger python at rcn.com
Tue Jun 10 01:33:48 CEST 2008

From: "Arnaud Delobelle" <arnodel at googlemail.com
>> As a consequence of Python method implementation, one could write instead:
>>    A = set.union(S, T, U, V)
>>    B = set.intersection(S, T, U, V)
>> which reads nicely
> I've written a patch [1] that does that.  Following the suggestion of
> Raymond Hettinger, I've implemented set.intersection by sorting all
> its sets/frozensets/dicts in increasing order of size first, then
> iterating over the smallest.  It's the first time I try my hand at
> this so it might not be up to much, but I've made it so I might as
> well send it :).  It's against py3k svn.
> [1] http://bugs.python.org/issue3069

Thanks.  It looks like I beat you to it.  But I will go over your code
and incorporate some version of the sorting for interections and
harvest the tests.   Also, I'll go ahead and add you to Misc/ACKS.


More information about the Python-ideas mailing list