Skip to content

gh-118150: warn in doc about results asymmetry for difflib junk#153892

Open
Lenormju wants to merge 4 commits into
python:mainfrom
Lenormju:gh-118150-difflib-autojunk-asymmetry-doc
Open

gh-118150: warn in doc about results asymmetry for difflib junk#153892
Lenormju wants to merge 4 commits into
python:mainfrom
Lenormju:gh-118150-difflib-autojunk-asymmetry-doc

Conversation

@Lenormju

@Lenormju Lenormju commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

@python-cla-bot

python-cla-bot Bot commented Jul 18, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app bedevere-app Bot added the docs Documentation in the Doc dir label Jul 18, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Jul 18, 2026
@read-the-docs-community

read-the-docs-community Bot commented Jul 18, 2026

Copy link
Copy Markdown

@encukou encukou added the sprint label Jul 18, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Sprint Jul 18, 2026
@encukou encukou self-assigned this Jul 18, 2026
Comment thread Doc/library/difflib.rst Outdated
Comment thread Doc/library/difflib.rst Outdated

This heuristic only ever inspects the second sequence for junk. That has
an unexpected consequence: swapping the inputs can produce a different
diff than simply reversing the output, sometimes very large.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds ungrammatical.
Do we need to note that output can be very large?

Suggested change
diff than simply reversing the output, sometimes very large.
diff than reversing the output.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think yes, because it is the original issue, and the most unexpected behavior. #118150 describes a pathological case where, depending on the inputs' order, the diff can be 1186x bigger. I call that surprising, and very large. In this case, it was because most lines got autojunked.

I will fix the grammar right now, sorry for that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reworded the two junk-related paragraphs.
About the size:

But it can also cause pathological cases where too many items considered junk cause an unexpectedly large (but correct) diff result.

Comment thread Doc/library/difflib.rst Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir sprint

Projects

Status: Todo
Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants