Currently I have a collection of hundreds of thousands of IDs as integers, and I am performing the following task (lets say this collection is stored in a list cache for now):
cache = list()
# lets say this cache is populated
for x in range(0,1000000):
if x not in cache:
#do_something
How expensive is it for me to use a list to search for not in something? Would I benefit from using another data structure, and if so which one would be best?