目前,我有一个这样的德克不断被附加到:
choices = [
["text approximately 500+ chars long", 1] #second part is a 1 or a 2
]
文本-电子邮件链中最新的电子邮件和号码决定了如何处理它。任何随后的电子邮件(链中较低的或链中较高的)都应该应用相同的操作。
我使用deque是因为我假设在同一个链中的电子邮件是在同一时间发送的,因此我可以从使用
appendleft
目前,为了实现我的目标,我正在这样做:
for choice in choices:
if current_email in choice[0]: #check for lower level emails
incident_type = choice[1]
break
elif choice[0] in current_email: #check for upper level emails
incident_type = choice[1]
break
我相信我目前的搜索方式是O(nkm)表示n(长度为
current_email
)和k(长度
choices
)m(电子邮件的长度,k),因此,这是一种非常次优的做事方式。一旦选择达到大约50个,则每次完整搜索选择需要大约5-10秒才能完成。有没有更好的方法来处理其他模块或方法?
谢谢您。