00:00 So, why sets? Well, sometimes you only care about unique values/you don’t want duplicates and you don’t need your data structure to be ordered. That’s the obvious difference between sets and tuples or lists, is not ordered and no duplicates. You can also do some cool operations very easily.
00:19 We have union, symmetric difference, you can mutate using difference update or symmetric difference update or disjoint or superset or subset or proper superset or something like that. Where with lists and tuples, that might be a little harder to do.
00:34 But the main reason that we use sets—or, I shouldn’t say the main reason—a very important reason we use sets is that they are very, very fast. What I mean by that is you can check for membership almost instantly.
00:47 So, let’s actually see how sets compare with lists and tuples in terms of checking for membership.
Become a Member to join the conversation.