my question is about algorithms for extract data from 2 list of instances which share same ID. Here is a example: ClassA has 2 attributes: ID and info, classB has 1 attribute: ID
listA listB
instanceA1 instanceB1
instanceA2 instanceB2
instanceA3
instanceA4
what I did is very simple
IDs_listB = [l.ID for l in listB]
out_tab=[]
for line in listA:
if line.ID in IDs_listB:
out_tab.append(line)
But this way become very slow and heavy for large data, if listA
has N lines and M lines for listB
, O(N*M) the total complexity is too much......
I am thinking of cython or a automate, but is there any way better to so this job?
thank you