Sets, and why speed depends on the container
A set holds unique items with no order: seen = {"A01", "A02"}. set(xs)
removes duplicates from a list. Like dict keys, checking x in seen is fast
however big the set gets.
x in some_list is different. Python checks the items one at a time, so it
gets slower as the list grows. That's fine once. Inside a loop it's a loop
inside a loop: with 10,000 items, about 100 million checks.
This is what time complexity describes. Checking a list is O(n): the work grows with the size. Checking a set is O(1): the work stays about the same. A list check inside a loop is O(n²).
Run the code and compare the two timings. Then try making n bigger. The
Performance challenges are all about spotting this.