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
bcd8988a
Commit
bcd8988a
authored
Dec 03, 2010
by
Terry Reedy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue 10534 deprecate isbjunk and isbpopular methods.
Will add gone in 3.3 test later.
parent
3a11e717
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
17 deletions
+16
-17
Lib/difflib.py
Lib/difflib.py
+16
-17
No files found.
Lib/difflib.py
View file @
bcd8988a
...
...
@@ -32,6 +32,7 @@ __all__ = ['get_close_matches', 'ndiff', 'restore', 'SequenceMatcher',
'Differ'
,
'IS_CHARACTER_JUNK'
,
'IS_LINE_JUNK'
,
'context_diff'
,
'unified_diff'
,
'HtmlDiff'
,
'Match'
]
import
warnings
import
heapq
from
collections
import
namedtuple
as
_namedtuple
...
...
@@ -182,7 +183,7 @@ class SequenceMatcher:
# we need to do to 'a' to change it into 'b'?"
# b2j
# for x in b, b2j[x] is a list of the indices (into b)
# at which x appears; junk elements do not appear
# at which x appears; junk
and popular
elements do not appear
# fullbcount
# for x in b, fullbcount[x] == the number of times x
# appears in b; only materialized if really needed (used
...
...
@@ -204,15 +205,6 @@ class SequenceMatcher:
# subtle but helpful effects on the algorithm, which I'll
# get around to writing up someday <0.9 wink>.
# DON'T USE! Only __chain_b uses this. Use isbjunk.
# isbjunk
# for x in b, isbjunk(x) == isjunk(x) but much faster;
# it's really the __contains__ method of a hidden dict.
# DOES NOT WORK for x in a!
# isbpopular
# for x in b, isbpopular(x) is true iff b is reasonably long
# (at least 200 elements) and x accounts for more than 1 + 1% of
# its elements (when autojunk is enabled).
# DOES NOT WORK for x in a!
# bjunk
# the items in b for which isjunk is True.
# bpopular
...
...
@@ -343,12 +335,19 @@ class SequenceMatcher:
popular
.
add
(
elt
)
del
b2j
[
elt
]
# Now for x in b, isjunk(x) == x in junk, but the latter is much faster.
# Since the number of *unique* junk elements is probably small, the
# memory burden of keeping this set alive is likely trivial compared to
# the size of b2j.
self
.
isbjunk
=
junk
.
__contains__
self
.
isbpopular
=
popular
.
__contains__
def
isbjunk
(
self
,
item
):
"Deprecated; use 'item in SequenceMatcher().bjunk'."
warnings
.
warn
(
"'SequenceMatcher().isbjunk(item)' is deprecated;
\
n
"
"use 'item in SMinstance.bjunk' instead."
,
DeprecationWarning
,
2
)
return
item
in
self
.
bjunk
def
isbpopular
(
self
,
item
):
"Deprecated; use 'item in SequenceMatcher().bpopular'."
warnings
.
warn
(
"'SequenceMatcher().isbpopular(item)' is deprecated;
\
n
"
"use 'item in SMinstance.bpopular' instead."
,
DeprecationWarning
,
2
)
return
item
in
self
.
bpopular
def
find_longest_match
(
self
,
alo
,
ahi
,
blo
,
bhi
):
"""Find longest matching block in a[alo:ahi] and b[blo:bhi].
...
...
@@ -406,7 +405,7 @@ class SequenceMatcher:
# Windiff ends up at the same place as diff, but by pairing up
# the unique 'b's and then matching the first two 'a's.
a
,
b
,
b2j
,
isbjunk
=
self
.
a
,
self
.
b
,
self
.
b2j
,
self
.
isbjunk
a
,
b
,
b2j
,
isbjunk
=
self
.
a
,
self
.
b
,
self
.
b2j
,
self
.
bjunk
.
__contains__
besti
,
bestj
,
bestsize
=
alo
,
blo
,
0
# find longest junk-free match
# during an iteration of the loop, j2len[j] = length of longest
...
...
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