gh-154661: Reorganize difflib documentation#154662
Open
encukou wants to merge 1 commit into
Open
Conversation
- Put common information in an intro section at the beginning, rather than in a duplicate doc entry for `SequenceMatcher` - Merge the two doc entries for `Differ` - Document timing as a CPython implementation detail - Group examples together
Documentation build overview
|
hugovk
reviewed
Jul 25, 2026
| Junk heuristic | ||
| -------------- | ||
|
|
||
| :mod:`!difflib` uses a :dfn:`junk` heuristic: Some items are deemed to be |
Member
There was a problem hiding this comment.
Suggested change
| :mod:`!difflib` uses a :dfn:`junk` heuristic: Some items are deemed to be | |
| :mod:`!difflib` uses a :dfn:`junk` heuristic: some items are deemed to be |
| ----------------------------- | ||
|
|
||
| The algorithm used in :class:`SequenceMatcher` predates, and is a little | ||
| fancier than, an algorithm published in the late 1980's by Ratcliff and |
Member
There was a problem hiding this comment.
Suggested change
| fancier than, an algorithm published in the late 1980's by Ratcliff and | |
| fancier than, an algorithm published in the late 1980s by Ratcliff and |
| The basic Ratcliff-Obershelp algorithm is cubic time in the worst | ||
| case and quadratic time in the expected case. | ||
| :mod:`difflib`'s algorithm is quadratic time for the worst case and has | ||
| expected-case behavior dependent in a complicated way on how many elements |
Member
There was a problem hiding this comment.
Suggested change
| expected-case behavior dependent in a complicated way on how many elements | |
| expected-case behavior dependent on a complicated way on how many elements |
Comment on lines
+124
to
+126
| because they synch up anywhere possible, sometimes at accidental matches | ||
| 100 pages apart. | ||
| Restricting synch points to contiguous matches preserves some notion of |
Member
There was a problem hiding this comment.
We use "sync" everywhere else, and avoids mispronunciation as "sinch" (which I have heard):
Suggested change
| because they synch up anywhere possible, sometimes at accidental matches | |
| 100 pages apart. | |
| Restricting synch points to contiguous matches preserves some notion of | |
| because they sync up anywhere possible, sometimes at accidental matches | |
| 100 pages apart. | |
| Restricting sync points to contiguous matches preserves some notion of |
Comment on lines
+146
to
+147
| be ignored. Read the description of the | ||
| :meth:`~SequenceMatcher.find_longest_match` method's *isjunk* |
Member
There was a problem hiding this comment.
Perhaps? (and may need an escape)
Suggested change
| be ignored. Read the description of the | |
| :meth:`~SequenceMatcher.find_longest_match` method's *isjunk* | |
| be ignored. Read the description of | |
| :meth:`~SequenceMatcher.find_longest_match`'s *isjunk* |
Comment on lines
+159
to
+160
| :meth:`~io.IOBase.readlines` method of file-like objects. The delta | ||
| generated also consists of newline-terminated strings, ready to be |
Member
There was a problem hiding this comment.
Suggested change
| :meth:`~io.IOBase.readlines` method of file-like objects. The delta | |
| generated also consists of newline-terminated strings, ready to be | |
| :meth:`~io.IOBase.readlines` method of file-like objects. The generated | |
| delta also consists of newline-terminated strings, ready to be |
Member
|
And let's backport (if trivial). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SequenceMatcherDiffer