[Pythonmac-SIG] Sets and Speed
Bob Ippolito
bob at redivi.com
Mon May 30 23:51:09 CEST 2005
On May 30, 2005, at 2:48 PM, Yair Benita wrote:
> I usually combine 2 sets using union but one set is much smaller
> than the other. It is better to do it using "add", as suggested,
> and that is my solution. I didn't realize that using "add" will not
> create redundancy, as you said these are like keys in a dictionary
> so no duplicates can occur. I suppose "union" is worth doing when I
> have two big sets to be combined.
Union is for combining two sets and creating a third set -- which
involves a lot of copying and reference counting. If you want to
combine two sets, simply mutating one, use update.
-bob
More information about the Pythonmac-SIG
mailing list