Prateek <[EMAIL PROTECTED]> wrote:

> >      For the above example, it's worth sorting lists_of_sets by the
> > length of the sets, and doing the short ones first.
> 
> Thanks. I thought so - I'm doing just that using a simple Decorate-
> Sort-Undecorate idiom.

Use, instead, the DSU that is now build into Python:

listofsets.sort(key=len)

this will be faster (as well as more readable &c) than programming your
own DSU, and is exactly the reason the key= parameter was added.

I also suggest avoiding reduce in favor of a simple explicit loop.


Alex
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to