Skip to content

Commit 7ed6c39

Browse files
committed
Docs: Clarify behavior of regular expression pattern caching as it relates to re.compile
1 parent 1963e70 commit 7ed6c39

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Doc/library/re.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -915,10 +915,15 @@ Functions
915915

916916
.. note::
917917

918-
The compiled versions of the most recent patterns passed to
919-
:func:`re.compile` and the module-level matching functions are cached, so
920-
programs that use only a few regular expressions at a time needn't worry
921-
about compiling regular expressions.
918+
In addition to caching patterns passed to :func:`re.compile`,
919+
the module maintains a small internal cache of regular
920+
expressions passed to matching functions such as
921+
:func:`re.search`, :func:`re.match`, and :func:`findall`,
922+
even if the regular expressions were passed to
923+
those functions as strings. Therefore, programs that use only
924+
a few regular expressions at a time needn't worry about
925+
compiling regular expressions.
926+
922927

923928

924929
.. function:: search(pattern, string, flags=0)

0 commit comments

Comments
 (0)