有list_a, list_b两个list
list_a 有大约 70000 个 elements
list_b 大约 3 million 个 elements
程式大致如下:
res_li = []
for x in list_b:
try:
res_li.append(list_a.index(x))
except:
res_li.append("")
对 list_b 中的每一个 element
在 list_a 中找到一样 element 把他的 index 加到新的 list 中
随着 iteration 增加 速度变得越来越慢,
想请教各位为何会有这个现象以及有什么方法加速这个 for loop 呢?
谢谢各位高手