Skip to content

Four insertion sorts become four calls - #3

Merged
martin-k-m merged 2 commits into
mainfrom
perf/sort-is-a-builtin-now
Sep 3, 2026
Merged

martin-k-m merged 2 commits into
mainfrom
perf/sort-is-a-builtin-now

Conversation

@martin-k-m

Copy link
Copy Markdown
Collaborator

docs/needs.md entry 12 closes. twill 1.9.0's sort orders numbers as well as strings and takes a comparison:

  • strutil.sort_strs goes straight through
  • manifest.sort_deps and lockfile.sort_entries order by compare_str on the name
  • resolve.sort_versions by semver.compare, because a version order is not a string order and 1.10.0 sorts after 1.9.0 rather than before it

The entry's complaint was not speed. Dependency lists are tens of entries and the quadratic cost was invisible. It was that four near-identical sorts differing only in the comparison are four places for the ordering a lockfile depends on to go wrong.

The builtin is stable, so a re-rendered lockfile still produces no diff.

CI and spool.toml move to 1.9.0 in the second commit. Six suites pass.

🤖 Generated with Claude Code

martin-k-m and others added 2 commits September 2, 2026 22:32
twill 1.9.0's sort orders numbers as well as strings and takes a
comparison, which is docs/needs.md entry 12. strutil.sort_strs goes
straight through; manifest.sort_deps and lockfile.sort_entries order by
compare_str on the name; resolve.sort_versions by semver.compare, because
a version order is not a string order and 1.10.0 sorts after 1.9.0.

The entry's complaint was not speed. Dependency lists are tens of entries
and the quadratic cost was invisible. It was that four near-identical
sorts differing only in the comparison are four places for the ordering a
lockfile depends on to go wrong.

The builtin is stable, so a re-rendered lockfile still produces no diff.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
CI installs v1.9.0 and spool.toml asks for ^1.9.0, because the sort this
branch adopts is in that release and not in the one pinned before it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@martin-k-m
martin-k-m merged commit 9a74568 into main Sep 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant