Repository navigation
fix: use input-length phases in parallel odd-even transposition sort - #15554
Draft
mohammmad357 wants to merge 2 commits into
Draft
mohammmad357 wants to merge 2 commits into
mohammmad357 wants to merge 2 commits into
Conversation
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.
Describe your change
The parallel odd-even transposition worker always performs ten phases. A
reverse-ordered eleven-item list therefore returns
[1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 10]instead oflist(range(11)).Pass the input length to every worker and perform that many phases, matching
the existing comment and the odd-even sorting network's bound.
Refs #10925 (closed). @gyan313 previously identified and proposed this phase
count approach in closed, unmerged #10976; credit for that earlier observation
and approach belongs to them. This patch only carries the phase count through
the existing worker arguments. Empty/singleton input handling and typing
refactors remain outside this diff.
I checked the open parallel-sort PRs #15493, #15513, #15531 and #15538:
their patches retain the ten-phase loop. This addresses a separate correctness
case, although changes to the same file may conflict if another PR lands first.
It does not resolve the whole comparable-types umbrella #15234.
Validation
215c1f0710f610aaf5ebaeab04edacec3f5308cd, branchfix-parallel-sort-phase-count; exactly one algorithm file changed.sortedpassed:reverse inputs of lengths 2, 3, 10, 11 and 12, twelve strings, fifteen seeded
duplicate/negative integers and twenty seeded floats. All returned the same
input list object. These checks use a standalone spawn-safe harness.
git diff --checkpassed.out on
files.pythonhosted.org;python -m pre_commit run --all-filesreports
No module named pre_commit. Python 3.15t was not tested locally.Leaving this as a draft until upstream CI and maintainer review are available;
local correctness is not claimed to replace those checks.
Prepared with AI coding assistance; no outside user feedback or ratings are
claimed. The earlier contributor is explicitly credited above.
Checklist
Unchecked items: this builds on the credited earlier approach; existing
unannotated parameters and worker doctest coverage are preserved; no new
algorithm or complete open issue is resolved. The newly added
phasesparameter has an
intannotation.