New submission from Recursing <buonanno.lore...@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 <rep...@bugs.python.org> <https://bugs.python.org/issue39195> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com