I have 2 lists of instances:
list1
list2
each instance contains variables such as id, name, etc…
I am iterating through list2, and I want to find entries that don’t exist in list1.
eg..
for entry in list2:
if entry.id in list1:
<do something>
I’m hoping to find a way to do this without a douple for loop. Is there an easy way?
I might do something like:
where
...is additional (hashable) attibutes of the instance — You need to include enough of them to make it unique.This takes your O(N*M) algorithm and turns it into an O(max(N,M)) algorithm.