here is a scenario, I am checking if elements of A are present in B. while this code works, it takes a lot of time when I read through million of lines. The efficient way would be to make each list in A and B as dictionary and look if they are present in each other. But I am not able to think of a simple way to do dictionary lookup. That is for each key-value pair in dict A, I want to check if that key-value pair is present in dictB
A = [['A',[1,2,3]],['D',[3,4]],['E',[6,7]]]
B= [['A',[1,2,3]],['E',[6,7]],['F',[8,9]]]
count = 0
for line in A:
if len(line[1]) > 1:
if line in B:
count = count + 1
print count
Example: