История изменений
Исправление Darth_Revan, (текущая версия) :
Note: The compiled versions of the most recent patterns passed to re.compile() and the module-level matching functions are cached, so programs that use only a few regular expressions at a time needn’t worry about compiling regular expressions.
Есть такое.
import re
for i in range(0, 500000):
if re.match(r"^w.*t$", "wut"):
pass
real 0m0,865s
user 0m0,851s
sys 0m0,009s
import re
regex = re.compile(r"^w.*t$")
for i in range(0, 500000):
if regex.match("wut"):
pass
real 0m0,364s
user 0m0,356s
sys 0m0,008s
Разрыв устойчивый. Python 3.6.5, x86-64.
Исправление Darth_Revan, :
Note: The compiled versions of the most recent patterns passed to re.compile() and the module-level matching functions are cached, so programs that use only a few regular expressions at a time needn’t worry about compiling regular expressions.
Есть такое.
import re
for i in range(0, 500000):
if re.match(r"^w.*t$", "wut"):
pass
real 0m0,865s
user 0m0,851s
sys 0m0,009s
import re
regex = re.compile(r"^w.*t$")
for i in range(0, 500000):
if regex.match("wut"):
pass
real 0m0,364s
user 0m0,356s
sys 0m0,008s
Результат устойчивый. Python 3.6.5, x86-64.
Исходная версия Darth_Revan, :
Note: The compiled versions of the most recent patterns passed to re.compile() and the module-level matching functions are cached, so programs that use only a few regular expressions at a time needn’t worry about compiling regular expressions.
Есть такое.
import re
for i in range(0, 500000):
if re.match(r"^w.*t$", "wut"):
pass
real 0m0,865s
user 0m0,851s
sys 0m0,009s
import re
regex = re.compile(r"^w.*t$")
for i in range(0, 500000):
if regex.match("wut"):
pass
real 0m0,364s
user 0m0,356s
sys 0m0,008s
Результат устойчивый.