我有两个字典列表:prices_distincts
, prices
.
它们通过 连接hash_brand_artnum
,它们都按hash_brand_artnum
我不明白为什么循环工作这么长时间排序:
如果长度
prices_distincts
为 100,000 它适用于30 min
但如果长度
prices_distincts
为 10,000 它适用于10 sec
.
代码:
prices_distincts = [{'hash_brand_artnum':1202},...,..]
prices = [{'hash_brand_artnum':1202,'price':12.077},...,...]
for prices_distinct in prices_distincts:
for price in list(prices):
if prices_distinct['hash_brand_artnum'] == price['hash_brand_artnum']:
print price['hash_brand_artnum']
#print prices
del prices[0]
else:
continue
我需要寻找价格相同的商品。价格与价格之间的关系是一对多的。和等价的团价['hash_brand_artnum']