[python]判重加速

原来的代码是使用list的结果慢的要死,总共有300W的数据,结果20W的时候处理数据基本就走不动了,最后发现是判重这里的效率太低了。

if name not in nameList:
  nameList.append(name)

最后使用set速度快了几千倍都不止,所有数据30秒内处理完成,发现使用dictset是一样快的

nameList=set()
nameList.add(name)
nameList=list(nameList)

你可能感兴趣的:([python]判重加速)