擅长:python、mysql、java
<p>你预计有多少时间?我测试了以下代码:</p>
<pre><code>_list = ['investmentproperty'] * 100000
_dict = [
'investment',
'property',
'something',
'else'
] * 1000
regex = re.compile("^(?:" + "|".join(_dict) + "){1,3}$")
for i in _list:
result = regex.match(i)
#cost 5.06s
for i in _list:
result = re.match("^(?:" + "|".join(_dict) + "){1,3}$", i)
#cost 11.04s
</code></pre>
<p>我认为10万长度的列表和4000长度的字典,这是一个不错的表现,对吧?你知道吗</p>