I want to check whether new items have appeared in the list B in each iteration of a simulation and if so append the new value(s) to A. From my research, I have come to the conclusion that this is the most common way to solve this (not using sets, I want to keep the list ordered):
A = ['aa', 'bb', 'cc']
B = ['aa', 'bb', 'cc', 'dd','ee'] # Read only
[A.append(b) for b in B if not b in A]
However, this approach seems quite computationally heavy and I wonder if this concern is justified? And if so, is there another approach with better performance?
I know that B will not be updated that often (probably in much less than 1% of the iterations), and that A might hold more values that are not present in B but should be kept.