bpo-2986: Allow disabling difflib's automatic junk heuristic #17082
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.
Added parameter for
autojunk
to theDiffer
class and thendiff
method to allow disabling the automatic junk heuristic.I am using difflib extensively as part of a current project. We are working across a large amount of text, and for our purposes quality is preferred over speed. We have examples of where the diff algorithm fails (fails meaning treats the majority of our input as one large deletion / addition) with autojunking enabled and does not without, meaning we are required to set this parameter to false for our purposes.
This parameter is not accessible to us from the API provided by difflib currently. To resolve this we have copied this out and modified it in a similar way to this PR.
The issue we are facing plus the suggestion to allow this parameter to be configured it mentioned by others in bpo-2986.
Thanks, Liam
https://bugs.python.org/issue2986