Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[WIP] gh-132166: Add check in find_longest_match for checking if sequences are identical#132167

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
jurgenwigg wants to merge4 commits intopython:main
base:main
Choose a base branch
Loading
fromjurgenwigg:gh-132166-check-sequences-if-they-are-identical

Conversation

@jurgenwigg
Copy link

@jurgenwiggjurgenwigg commentedApr 6, 2025
edited by bedevere-appbot
Loading

As mentioned in#132166 added checking if both sequences are identical at the beginning of the methodfind_longest_match inSequenceMatcher class.

@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

Copy link
Member

@sobolevnsobolevn left a comment

Choose a reason for hiding this comment

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

Please, see my question in#132166 (comment)

Comment on lines +4 to +5
It appears to fix issue when comparing two slightly different strings ends up
with waiting forever for the result.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
It appears to fix issue when comparing two slightly different strings ends up
with waiting forever for the result.
It appears to fix issue when comparing two slightly different strings ends up
with waiting forever for the result.

We should be more confident here. Does it fix the issue or not? if so, let's say it. Otherwise, let's not give tentative conclusions.

jurgenwigg reacted with thumbs up emoji
Comment on lines +1 to +3
Add checking if sequences ``a[alo:ahi]`` and ``b[blo:bhi]`` are the same on the
beginning of the method find_longest_match in SequenceMatcher. For identical
sequences there is no reason to run whole logic when simple check can be done.
Copy link
Member

Choose a reason for hiding this comment

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

This NEWS should be summarized. I suggest something like (assumiong that the method is documented, if not use a plain

Add a fast path in:meth:`SequenceMatcher.find_longest_match<difflib.SequenceMatcher.find_longest_match>` to handle thecase when ``a[alo:ahi] == b[blo:bhi]``.

jurgenwigg reacted with thumbs up emoji

# Check if both sequences are the same before executing rest of the
# method.
if a[alo:ahi] == b[blo:bhi]:
Copy link
Member

Choose a reason for hiding this comment

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

Is this covered in tests? if not, please add a test, otherwise no need to add a large one.

jurgenwigg reacted with thumbs up emoji
@jurgenwiggjurgenwigg changed the titlegh-132166: Add check in find_longest_match for checking if sequences are identical[WIP] gh-132166: Add check in find_longest_match for checking if sequences are identicalApr 7, 2025
@python-cla-bot
Copy link

The following commit authors need to sign the Contributor License Agreement:

CLA signed

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@sobolevnsobolevnsobolevn left review comments

@picnixzpicnixzpicnixz left review comments

@brianschubertbrianschubertbrianschubert left review comments

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@jurgenwigg@sobolevn@picnixz@brianschubert

[8]ページ先頭

©2009-2026 Movatter.jp