Which one of these is faster? Is one “better”? Basically I’ll have two sets and I want to eventually get one match from between the two lists. So really I suppose the for loop is more like:
for object in set:
if object in other_set:
return object
Like I said – I only need one match, but I’m not sure how intersection() is handled, so I don’t know if its any better. Also, if it helps, the other_set is a list near 100,000 components and the set is maybe a few hundred, max few thousand.
Times:
Making them into sets in the setup and running 10000 runs instead of 100 yields
So your version is much faster whether or not it makes sense to convert them to sets.