Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-119105: difflib.py Differ.compare is too slow [for degenerate cases] #119376

Merged
merged 5 commits into from
May 22, 2024

Conversation

tim-one
Copy link
Member

@tim-one tim-one commented May 22, 2024

A different approach, tracking all ascending index pairs achieving the best ratio. None of them needs recursion then. And, more importantly, it restores difflib's general "top to bottom" ordering of matches.

@tim-one tim-one merged commit 07df93d into python:main May 22, 2024
31 checks passed
@tim-one tim-one deleted the differ branch May 22, 2024 23:25
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
…e cases] (python#119376)

Track all pairs achieving the best ratio in Differ(). This repairs the "very deep recursion and cubic time" bad cases in a way that preserves previous output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

difflib.py Differ.compare is too slow [for degenerate cases]
1 participant