-
-
Notifications
You must be signed in to change notification settings - Fork 33k
Closed as not planned
Closed as not planned
Copy link
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dirpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtopic-regex
Description
Documentation
The current documentation for the re.compile
function mentions that compiled regular expressions are cached, but the wording could be more precise to clarify that this caching also applies to patterns passed as strings to other module functions (e.g., re.search
, re.match
). This change would help guide developers away from unnecessarily calling re.compile
.
This abbreviated code snippet demonstrates the behavior I am referring to:
import re
re.match(r"fo+", "fooooooo")
for cache_entry in re._cache.items():
print(cache_entry)
#> ((<class 'str'>, 'fo+', 0), re.compile('fo+'))
Linked PRs
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dirpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtopic-regex
Projects
Status
Todo