mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
The note about caching of regular expression objects was incorrect ReST and
thus invisible in the compiled documentation. Fixed. Also I cleaned up the wording.
This commit is contained in:
parent
ad58b7c9da
commit
0261e5d0b6
1 changed files with 12 additions and 8 deletions
|
@ -440,19 +440,23 @@ form.
|
||||||
|
|
||||||
The sequence ::
|
The sequence ::
|
||||||
|
|
||||||
prog = re.compile(pat)
|
prog = re.compile(pattern)
|
||||||
result = prog.match(str)
|
result = prog.match(string)
|
||||||
|
|
||||||
is equivalent to ::
|
is equivalent to ::
|
||||||
|
|
||||||
result = re.match(pat, str)
|
result = re.match(pattern, string)
|
||||||
|
|
||||||
but the version using :func:`compile` is more efficient when the expression
|
but using :func:`compile` and saving the resulting regular expression object
|
||||||
will be used several times in a single program.
|
for reuse is more efficient when the expression will be used several times
|
||||||
|
in a single program.
|
||||||
|
|
||||||
.. (The compiled version of the last pattern passed to :func:`re.match` or
|
.. note::
|
||||||
:func:`re.search` is cached, so programs that use only a single regular
|
|
||||||
expression at a time needn't worry about compiling regular expressions.)
|
The compiled versions of the most recent patterns passed to
|
||||||
|
:func:`re.match`, :func:`re.search` or :func:`re.compile` are cached, so
|
||||||
|
programs that use only a few regular expressions at a time needn't worry
|
||||||
|
about compiling regular expressions.
|
||||||
|
|
||||||
|
|
||||||
.. data:: I
|
.. data:: I
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue