This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Recursing
Recipients Recursing
Date 2020-01-02.18:59:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1577991570.36.0.292103009672.issue39195@roundup.psfhosted.org>
In-reply-to
Content
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)
History
Date User Action Args
2020-01-02 18:59:30Recursingsetrecipients: + Recursing
2020-01-02 18:59:30Recursingsetmessageid: <1577991570.36.0.292103009672.issue39195@roundup.psfhosted.org>
2020-01-02 18:59:30Recursinglinkissue39195 messages
2020-01-02 18:59:30Recursingcreate