I have a list that contains 10**7 lists in the format:
big_list = [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7], [2, 3, 4, 26, 33, 40], [10, 23, 33, 45, 46, 47]]
Every list contains 6 unique ints.
I need to compare every list to another list:
lst = [1, 3, 4, 10, 23, 46]
and return those where list item intersection is less than 3.
So newlist would be:
new_list = [[2, 3, 4, 5, 6, 7], [2, 3, 4, 26, 33, 40]]
At the moment I’m using set intersection, but it takes about 30 seconds to run
1 Answer