I present the following example. I have two lists, one total and one with processed elements. The idea is, as the example shows, to eliminate the elements that have already been processed. The problem is that with the real data, that takes me 13 minutes! Surely it can be optimized in some way. Please help.
processed = ['a','b','c']
total = [(1, 'a', 'alaksdl'),
(2, 'x', 'asda'),
(3, 'b', 'asda'),
(4, 'c', 'wef'),
(5, 'e', 'asaaa'),
(5, 'j', 'asd')
]
start = time.time()
result = [x for x in total if x[1] not in processed]
end = time.time()
print("Time: ",round(end - start,5), " segundos")
Time: 0.00014 segundos
[(2, 'x', 'asda'), (5, 'e', 'asaaa'), (5, 'j', 'asd')]
result