Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 754ba58

Browse files
committed
Improve accuracy. In the .tex file, note the new "% BUG:" comments: an
extra backslash is getting displayed in the generated HTML.
1 parent f0768c8 commit 754ba58

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

Doc/lib/libdifflib.tex

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ \section{\module{difflib} ---
5353
\strong{Timing:} The basic Ratcliff-Obershelp algorithm is cubic
5454
time in the worst case and quadratic time in the expected case.
5555
\class{SequenceMatcher} is quadratic time for the worst case and has
56-
expected-case behavior dependent on how many elements the sequences
57-
have in common; best case time (no elements in common) is linear.
56+
expected-case behavior dependent in a complicated way on how many
57+
elements the sequences have in common; best case time is linear.
5858
\end{classdesc}
5959

6060

@@ -68,6 +68,9 @@ \subsection{SequenceMatcher Objects \label{sequence-matcher}}
6868
\code{None} is equivalent to passing \code{lambda x: 0}, i.e.\ no
6969
elements are ignored. For example, pass
7070

71+
% BUG: the HTML generated for this is
72+
% BUG: lambda x: x in " \\t"
73+
% BUG: i.e. it displays two backslashes.
7174
\begin{verbatim}
7275
lambda x: x in " \\t"
7376
\end{verbatim}
@@ -138,7 +141,7 @@ \subsection{SequenceMatcher Objects \label{sequence-matcher}}
138141
junk happens to be adjacent to an interesting match.
139142

140143
Here's the same example as before, but considering blanks to be junk.
141-
That prevents \code{' abcd'} from matching the \code{ abcd} at the
144+
That prevents \code{' abcd'} from matching the \code{' abcd'} at the
142145
tail end of the second sequence directly. Instead only the
143146
\code{'abcd'} can match, and matches the leftmost \code{'abcd'} in
144147
the second sequence:
@@ -217,8 +220,8 @@ \subsection{SequenceMatcher Objects \label{sequence-matcher}}
217220
range [0, 1].
218221

219222
Where T is the total number of elements in both sequences, and M is
220-
the number of matches, this is 2,0*M / T. Note that this is \code{1}
221-
if the sequences are identical, and \code{0} if they have nothing in
223+
the number of matches, this is 2.0*M / T. Note that this is \code{1.}
224+
if the sequences are identical, and \code{0.} if they have nothing in
222225
common.
223226

224227
This is expensive to compute if \method{get_matching_blocks()} or
@@ -242,8 +245,10 @@ \subsection{SequenceMatcher Objects \label{sequence-matcher}}
242245
\method{ratio()} or \method{quick_ratio()}.
243246
\end{methoddesc}
244247

245-
The three methods that return the ratio of differences to similarities
246-
can give different results due to differing levels of approximation:
248+
The three methods that return the ratio of matching to total characters
249+
can give different results due to differing levels of approximation,
250+
although \method{quick_ratio()} and \method{real_quick_ratio()} are always
251+
at least as large as \method{ratio()}:
247252

248253
\begin{verbatim}
249254
>>> s = SequenceMatcher(None, "abcd", "bcde")

Lib/difflib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@
9292
simple code building on SequenceMatcher can be used to do useful work.
9393
9494
Timing: Basic R-O is cubic time worst case and quadratic time expected
95-
case. SequenceMatcher is quadratic time worst case and has expected-case
96-
behavior dependent on how many elements the sequences have in common; best
97-
case time (no elements in common) is linear.
95+
case. SequenceMatcher is quadratic time for the worst case and has
96+
expected-case behavior dependent in a complicated way on how many
97+
elements the sequences have in common; best case time is linear.
9898
9999
SequenceMatcher methods:
100100

0 commit comments

Comments
 (0)