Repository navigation
Conversation
Avoid scanning prefixes when exact built-in strings or bytes match. Keep custom sequence equality on the existing scoring path and cover cutoffs, processor calls, full-range alignment and subclass equality. Related to rapidfuzz#430. Assisted-by: OpenAI Codex
This branch has not been deployed
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.
Related to #430.
The Python implementation of
partial_ratio_alignmentcompares prefixes before reaching the complete string, even when both strings are equal. Return the full-range alignment immediately for equal, exact built-instrorbytesinputs after preprocessing and sequence conversion.partial_ratiobenefits through its existing delegation.The exact-type guard deliberately leaves subclasses and other sequences on the existing path, so custom or ambiguous equality cannot replace element-wise scoring. It retains the cutoff check, processor calls, alignment coordinates, and existing nonempty perfect-score representation. Empty-input handling is unchanged. This only improves the Python fallback; it does not resolve the native implementation or interruption behavior discussed in #430.
Local measurements on Ubuntu 22.04 / Python 3.12.15, comparing the Python implementation at
e5ba5955with this change:These are medians of five alternating-order samples on one machine, with the benchmark process pinned to one CPU. Other host activity was not excluded, so the small unequal-input differences are approximate. The equality check adds work when strings differ; this is not a claim of a speedup for every workload or for the native implementation. A minimal timing command to run on each revision is:
Verification:
test_score_cutoff_equal_to_score[scorer9]; Python selection additionally fails the threetest_extract*exceptionscases. The full suite is therefore not green locally.git diff --checkpass. Documentation, packaging, other operating systems and other Python versions were not tested.Draft pending review of that baseline limitation. Implemented, reviewed, and verified with OpenAI Codex assistance.