So I have this script,
# g f z n
a = [(4264, 7, 1526, 0),
(4293, 14, 846, 93),
(4174, 6, 962, 0),
(4256, 12, 121, 0),
(4257, 29, 182, 385)
]
#list a ca. 200,000 entries
# g f z n id
b = [(4264, 10, 397, 0, 113),
(4264, 20, 95, 0, 114),
(4279, 13, 41, 0, 115),
(4293, 14, 846, 93, 116),
(4264, 8, 94, 0, 117),
(4264, 8, 92, 0, 118),
(4256, 12, 121, 0,119),
(4264, 9, 293, 82, 120),
(4264, 9, 288, 0, 121),
(4264, 8, 90, 25, 122),
(4264, 9, 156, 0, 123)
]
#list b ca. 1,000,000 entries
# My approach works, but takes a very very long time (over all entries)! Does anyone know a faster method?
for i in a:
for x in b:
if i[0] == x[0] and i[1] == x[1] and i[2] == x[2] and i[3] == x[3]:
xyz.append(x[4])
print(xyz)
# id
#### The desired result: [(116),
# (119)
# ]
The individual entries (lists) in the lists are fixed and differ only at the end by the "ID" in list b.
The aim is to get the ID's from list b where the entry (list) exists in list a.
My approach works, but takes a very very long time (over all entries,list a ca. 200,000 and list b ca. 1,000,000 entries)!
Does anyone know a faster method?