Say I have two lists with 100,000 elements each and I want to find the set difference but keep the order of the elements. Example:
A = [10, 1, 30, 4, 5, 6]
B = [4, 1, 100]
desired output:
AB = [10, 30, 5, 6]
set(A).difference(set(B)) is producing [10, 5, 6, 30] (notice how it doesn't preserve the order in A) and list comprehension is taking some time (I think it's because of the in operator).