@@ -114,16 +114,16 @@ class SequenceMatcherBase:
114114 """Base class for implementing sequence matchers.
115115
116116 At minimum, derived classes must implement `_get_matching_blocks` method,
117- which returns a list of blocks tuple[ start_in_a, start_in_b, length] .
117+ which returns a list of tuples of the form ( start_in_a, start_in_b, length) .
118118 See `_get_matching_blocks` and `get_matching_blocks` for more information.
119119
120- Once implemented, the following methods make use of it and are available:
121- get_matching_blocks
122- get_opcodes
123- get_grouped_opcodes
124- ratio
125- quick_ratio
126- real_quick_ratio
120+ Once implemented, the following methods are available:
121+ - get_matching_blocks
122+ - get_opcodes
123+ - get_grouped_opcodes
124+ - ratio
125+ - quick_ratio
126+ - real_quick_ratio
127127
128128 See `SequenceMatcher` for example implementation.
129129 """
@@ -217,10 +217,10 @@ def set_seq2(self, b):
217217 1.0
218218 >>>
219219
220- SequenceMatcherBase inends to cache detailed information about the
220+ SequenceMatcherBase caches detailed information about the
221221 second sequence. set_seq2 clears cache of quick_ratio method.
222222 In addition _prepare_seq2, which is called at the end of set_seq2,
223- can be implemented by derrived class for alignment algorithm cache logic.
223+ can be implemented by derived class for alignment algorithm cache logic.
224224
225225 See also set_seqs() and set_seq1().
226226 """
@@ -235,7 +235,7 @@ def set_seq2(self, b):
235235 def _prepare_seq2 (self ):
236236 """Preparation method that is called at the end of `set_seq2`.
237237
238- By default it does nothing, but can be implemented by derrived class
238+ By default it does nothing, but can be implemented by derived class
239239 for alignment algorithm cache logic.
240240 """
241241 pass
@@ -688,7 +688,8 @@ def find_longest_match(self, alo=0, ahi=None, blo=0, bhi=None):
688688 # Windiff ends up at the same place as diff, but by pairing up
689689 # the unique 'b's and then matching the first two 'a's.
690690
691- a , b , b2j , bjunk = self .a , self .b , self .b2j , self .bjunk
691+ a , b , b2j = self .a , self .b , self .b2j
692+ bjunk , bpopular = self .bjunk , self .bpopular
692693 if ahi is None :
693694 ahi = len (a )
694695 if bhi is None :
@@ -716,13 +717,12 @@ def find_longest_match(self, alo=0, ahi=None, blo=0, bhi=None):
716717 j2len = newj2len
717718
718719 block = besti , bestj , bestsize
719- if self . autojunk :
720+ if bpopular :
720721 # Extend the best by non-junk elements on each end. In particular,
721722 # "popular" non-junk elements aren't in b2j, which greatly speeds
722723 # the inner loop above, but also means "the best" match so far
723724 # doesn't contain any junk *or* popular non-junk elements.
724- block = _expand_block_to_junk (
725- bjunk , block , a , b , alo , ahi , blo , bhi , inverse = True )
725+ block = _expand_block_to_junk (bpopular , block , a , b , alo , ahi , blo , bhi )
726726
727727 if bjunk :
728728 # Now that we have a wholly interesting match (albeit possibly
@@ -732,8 +732,7 @@ def find_longest_match(self, alo=0, ahi=None, blo=0, bhi=None):
732732 # figuring out what to do with it. In the case of an empty
733733 # interesting match, this is clearly the right thing to do,
734734 # because no other kind of match is possible in the regions.
735- block = _expand_block_to_junk (
736- bjunk , block , a , b , alo , ahi , blo , bhi , inverse = False )
735+ block = _expand_block_to_junk (bjunk , block , a , b , alo , ahi , blo , bhi )
737736
738737 return Match ._make (block )
739738
@@ -1478,7 +1477,7 @@ def ndiff(a, b, linejunk=None, charjunk=IS_CHARACTER_JUNK, differ=None):
14781477 functions, or can be None:
14791478
14801479 - linejunk: A function that should accept a single string argument and
1481- return true iff the string is junk. The default is None, and is
1480+ returns true iff the string is junk. The default is None, and is
14821481 recommended; the underlying SequenceMatcher class has an adaptive
14831482 notion of "noise" lines.
14841483
0 commit comments