Skip to content

perf: fast path single-token repository search - #10906

Merged
radoering merged 2 commits into
python-poetry:mainfrom
dhimasardinata:dhimas/fast-single-token-search
May 24, 2026
Merged

radoering merged 2 commits into
python-poetry:mainfrom
dhimasardinata:dhimas/fast-single-token-search

Conversation

@dhimasardinata

Copy link
Copy Markdown
Contributor

Repository.search() and simple root-page search commonly receive a single string token from poetry search, but both paths currently wrap it in a one-item list and run any(...) for every package name.

This keeps list-query behavior unchanged and adds a direct string path for the common case.

A small local benchmark over 10,003 package names:

old 1.351595s
new 0.141769s
speedup=9.5x

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code. N/A, no user-facing behavior change.

Local checks:

PYTHONPATH=src uv run --with pytest --with pytest-xdist --with responses --with pytest-mock python -m pytest tests/repositories/test_repository.py tests/repositories/link_sources/test_base.py tests/repositories/test_repository_pool.py -q
uv run --with ruff python -m ruff check src/poetry/repositories/repository.py src/poetry/repositories/link_sources/base.py tests/repositories/test_repository.py
uv run --with ruff python -m ruff format --check src/poetry/repositories/repository.py src/poetry/repositories/link_sources/base.py tests/repositories/test_repository.py
PYTHONPATH=src uv run --with poetry-core --with packaging --with mypy python -m mypy src/poetry/repositories/repository.py src/poetry/repositories/link_sources/base.py
git diff --check

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@radoering
radoering force-pushed the dhimas/fast-single-token-search branch from 07939d0 to 10b6ced Compare May 24, 2026 15:02
@radoering
radoering enabled auto-merge (squash) May 24, 2026 15:10
@radoering
radoering merged commit dd7811a into python-poetry:main May 24, 2026
53 checks passed
@github-actions

Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jun 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants