i have two lists of tuples, where tuples in the each list are all unique. lists have the following format:
[('col1', 'col2', 'col3', 'col4'), ...]
i'm using a nested loop to find the members from both lists that have the same values for given cols, col2 and col3
temp1 = set() temp2 = set() for item1 in list1: for item2 in list2: if item1['col2'] == item2['col2'] and \ item1['col3'] == item2['col3']: temp1.add(item1) temp2.add(item2)
simply working. but it takes many minutes to complete when there are tens of thousands of items in lists.
Using tabular, i can filter list1 agianst col2, col3 of one item for list2 as given below:
list1 = tb.tabular(records=[...], names=['col1','col2','col3','col4']) ... for (col1, col2, col3, col4) in list2: list1[(list1['col2'] == col2) & (list1['col3'] == col3)]
which is obviously "doing it wrong" and way much slower than the first.
how can i effectively check items of a list of tuples against all the items of another using numpy or tabular?