improving a huge double-for cycle

Terry Reedy tjreedy at udel.edu
Fri Sep 19 00:46:02 EDT 2008


Steven D'Aprano wrote:
> On Thu, 18 Sep 2008 20:43:00 +0200, Bruno Desthuilliers wrote:
> 
>> Now the obvious winner is pruebono - even unoptimized, using sets seems
>> to be *way* faster than even the most optimized corrected version of
>> your algorithm.
> 
> I'm not being snarky about losing priority here, but I submitted 
> essentially the same solution two hours earlier than pruebono.
> 
> Are people not seeing my posts? Have I been kill-filed by everyone except 
> Mensator? I also asked a question about HTTPError and I haven't seen any 
> responses at all.

Yes, after figuring out what to do from the original post, I saw yours 
and then Pruebono's and decided that since two people had submitted the 
jackpot algorithm, I need not say more.  I will say this: this solution 
amounts to finding equivalence classes (the sets of items with a given 
'key') and then finding the classes (sets) with more than one member. 
Defaultdict is great for this.

tjr




More information about the Python-list mailing list