Repository navigation
Improvement: #13420 - Update logic of nodes._check_initialpaths_for_relpath - #13448
Merged
nicoddemus merged 7 commits intoMay 29, 2025
Merged
nicoddemus merged 7 commits into
nicoddemus merged 7 commits into
Conversation
RonnyPfannschmidt
approved these changes
May 28, 2025
RonnyPfannschmidt
left a comment
Member
There was a problem hiding this comment.
Clever
Let's associate the pr id and mention further improvement
update AUTHORS
for more information, see https://pre-commit.ci
RonnyPfannschmidt
previously requested changes
May 28, 2025
nicoddemus
approved these changes
May 28, 2025
nicoddemus
dismissed
RonnyPfannschmidt’s stale review
May 28, 2025 21:22
Changelog updated as requested.
Member
Yes, you are welcome to. 👍 |
RonnyPfannschmidt
approved these changes
May 28, 2025
Contributor
Author
|
@nicoddemus thanks for editing the changelog entry! |
Contributor
Author
|
@nicoddemus @RonnyPfannschmidt |
Backport to 8.3.x: 💚 backport PR created✅ Backport PR branch: Backported as #13451 🤖 @patchback |
nicoddemus
added a commit
that referenced
this pull request
May 29, 2025
…13451) Use `Path` facilities to greatly improve performance of `nodes._check_initialpaths_for_relpath` (see #13448 for performance comparison). Related: #13420, #13413. --------- (cherry picked from commit bd6877e) Co-authored-by: Sashko <20253875+sashko1988@users.noreply.github.com> Co-authored-by: Bruno Oliveira <bruno@soliv.dev>
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.
Updates logic of
nodes._check_initialpaths_for_relpathAn even better fix for #13420 and this discussion - #13413
I still wasn't quite happy with the performance.
So after close examination of what
nodes._check_initialpaths_for_relpathdoes, I came up with the PR changes.Previous logic:
initial_paths.Instead, I propose the following:
initial_paths.relative_towill return".", and function should return""initial_paths. If it is, then return the relative path of the given path and that parent.Performance changes for collecting 1000 tests with stucture described in #13420 and #13413 (times are almost the same for main and 8.3.x branches):
Base
ncalls tottime percall cumtime percall filename:lineno(function) 5821 2.591 0.000 83.172 0.014 nodes.py:547(_check_initialpaths_for_relpath)With improved logic
ncalls tottime percall cumtime percall filename:lineno(function) 5821 0.020 0.000 0.337 0.000 nodes.py:547(_check_initialpaths_for_relpath)PS Couple of questions: