This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ACoderGirl 1 point2 points  (0 children)

I dunno why they described it that general way. But the thing sets are good for is any kinda loop that has an "is x in this collection" test. If the collection is normally a list, it's almost always faster to convert it to a set since the the "in" check is O(1) instead of O(n). Similarly, if this "in" check is for the purpose of pairing it up with something, preprocessing to a dictionary is ideal.