I am trying a substring list with another list.The substring list looks like this:
area_index = ['sel_reg','sel_reg/clk1','top_mod/pcb/clk_reg','hello']
There is another list looks like this:
power_index = ['gpu_gpc_wrap/sel_reg/clk1','top_mod/pcb/clk_reg','gpu/gpu_gpc_wrap/sel_reg','top_mod/clk_bus']
I need to know if the element in area_index is a substring of one of the element in power_index. For example, 'sel_reg/clk1' is a substring of 'gpu_gpc_wrap/sel_reg/clk1' in power_index, while 'hello' is not a substring of any element in power_index. So i wrote a piece of code to solve the problem:
not_in = []
for gpc_name in area_index:
find = False
for p_name in power_index:
if p_name.find(gpc_name) != -1:
find = True
power_index.remove(p_name)
break
if not find:
not_in.append(gpc_name)
print(not_in)
Actually, it works. However, as the length of power_index or area_index increases, it becomes impossible for my computer to finish the task in a reasonable time.
What should I do to improve the performance?