[Python-ideas] Implement __add__ for set and frozenset

Arnaud Delobelle arnodel at googlemail.com
Tue Jun 10 02:45:52 CEST 2008


On 10 Jun 2008, at 00:33, Raymond Hettinger wrote:

> 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.

Thanks!  I'm a bit ashamed of the tests though.

-- 
Arnaud




More information about the Python-ideas mailing list