
June 3, 2008
1:28 a.m.
On Mon, Jun 2, 2008 at 9:21 PM, George Sakkis <george.sakkis@gmail.com> wrote:
Regardless of the operator, that's a pretty inefficient way of doing "unionall"; it creates N-1 intermediate result sets that discards them right after they are added. It should be written as:
big_u = set() for s in all_sets: big_u.update(s)
I wouldn't mind having a standard unionall, but not every 3-line function has to be in the stdlib.
George
I thought max was implemented using += (i.e. it usually starts at 0 and uses += on each item in the iterable). If so, implementing ** _iadd_ ** would result in exactly the code you posted. I realize that I said __add__ in the first place, but __iadd__ is really what I meant. Brandon