Skip to content

perf: use built-in sorted() in DsList.sort_list#35

Open
m-truscott wants to merge 1 commit into
mainfrom
perf-dslist-builtin-sort
Open

perf: use built-in sorted() in DsList.sort_list#35
m-truscott wants to merge 1 commit into
mainfrom
perf-dslist-builtin-sort

Conversation

@m-truscott
Copy link
Copy Markdown

Summary

Replace the hand-rolled O(n²) bubble sort in DsList.sort_list with Python's built-in sorted(), improving performance and readability.

Changes

  • Replace nested-loop bubble sort with sorted(v) in src/llm_benchmark/datastructures/dslist.py
  • Remove 6 lines of manual swap logic

Validation

Validation commands configured for this project (run to verify the change is safe):

  • Compilation: uv pip install poetry && python -m poetry install
  • Unit tests: python -m poetry run pytest --benchmark-skip tests/
  • Benchmark: python -m poetry run pytest --benchmark-only tests/

Notes

sorted() returns a new list, preserving the original non-mutating behaviour of the previous implementation. Both produce identical ascending-order output for List[int].


changeset_id: ec82b078-0eba-4148-bb3b-c831e6a77c1d

Trigger Artemis Fix Agent to iterate on comments left on your PR

  1. Wait until your reviewers are done leaving comments on the PR.
  2. Tag @artemis-fix-agent in a new comment — this will be your trigger comment. Optionally, add further instructions you want Artemis to act on.

Example trigger comment:

@artemis-fix-agent address all the review feedback above.

Artemis will pick up all existing PR comments automatically. Note that each time you tag @artemis-fix-agent, a separate, parallel fix attempt will be kicked off, so only tag Artemis once you're ready to start.

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.

2 participants