[New-bugs-announce] [issue39195] re._compile should check if the argument is a compiled pattern before checking cache and flags
Recursing
report at bugs.python.org
Thu Jan 2 13:59:30 EST 2020
New submission from Recursing <buonanno.lorenzo at gmail.com>:
In the re module, re._compile gets called when using most re methods.
In my use case (which I think is not rare) I have a small number of compiled patterns that I have to match against a large number of short strings
profiling showed that half of the total runtime was still spent in re._compile, checking for the type of the flags and trying to get the pattern in a cache
Example code that exhibits this behavior:
import re
pattern = re.compile("spam")
string = "Monty pythons"
for _ in range(1000000):
re.search(pattern, string)
----------
components: Library (Lib)
messages: 359210
nosy: Recursing
priority: normal
severity: normal
status: open
title: re._compile should check if the argument is a compiled pattern before checking cache and flags
type: performance
versions: Python 3.8, Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39195>
_______________________________________
More information about the New-bugs-announce
mailing list