Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
26d80e67
Commit
26d80e67
authored
Jul 15, 1997
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correct inf. while loop.
parent
e8b81313
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
5 deletions
+20
-5
Lib/re.py
Lib/re.py
+20
-5
No files found.
Lib/re.py
View file @
26d80e67
...
...
@@ -58,20 +58,34 @@ def valid_identifier(id):
#
#
_cache
=
{}
_MAXCACHE
=
20
def
_cachecompile
(
pattern
,
flags
):
key
=
(
pattern
,
flags
)
try
:
return
_cache
[
key
]
except
KeyError
:
pass
value
=
compile
(
pattern
,
flags
)
if
len
(
_cache
)
>=
_MAXCACHE
:
_cache
.
clear
()
_cache
[
key
]
=
value
return
value
def
match
(
pattern
,
string
,
flags
=
0
):
return
compile
(
pattern
,
flags
).
match
(
string
)
return
_cache
compile
(
pattern
,
flags
).
match
(
string
)
def
search
(
pattern
,
string
,
flags
=
0
):
return
compile
(
pattern
,
flags
).
search
(
string
)
return
_cache
compile
(
pattern
,
flags
).
search
(
string
)
def
sub
(
pattern
,
repl
,
string
,
count
=
0
):
return
compile
(
pattern
).
sub
(
repl
,
string
,
count
)
return
_cache
compile
(
pattern
).
sub
(
repl
,
string
,
count
)
def
subn
(
pattern
,
repl
,
string
,
count
=
0
):
return
compile
(
pattern
).
subn
(
repl
,
string
,
count
)
return
_cache
compile
(
pattern
).
subn
(
repl
,
string
,
count
)
def
split
(
pattern
,
string
,
maxsplit
=
0
):
return
compile
(
pattern
).
subn
(
string
,
maxsplit
)
return
_cache
compile
(
pattern
).
subn
(
string
,
maxsplit
)
#
#
...
...
@@ -1064,6 +1078,7 @@ def compile(pattern, flags=0):
Label
(
label
)]
+
\
stack
[
-
1
]
+
\
[
Label
(
label
+
1
)]
max
=
max
-
1
label
=
label
+
2
del
stack
[
-
1
]
stack
.
append
(
expr
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment