Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-117349: Micro-optimize a fewos.path functions#117350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
nineteendo commentedMar 29, 2024
I believe that's everything. If you would like these changes to be split up in multiple pull requests let me know. |
Uh oh!
There was an error while loading.Please reload this page.
AlexWaygood left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
As@sobolevn says, it's very difficult to see here which changes are actually related to performance improvements, and which are simply cosmetic changes that have no impact on how the code works. Our general policy is not to accept cosmetic changes, but even if we decided that we wanted to make an exception here, any such stylistic/formatting improvements would have to go into their own PR, so that the git history clearly showed which changes were performance-related and which were cosmetic.
Please revert all changes that do not actually have any impact on performance.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Uh oh!
There was an error while loading.Please reload this page.
nineteendo commentedMar 29, 2024
Does that include unnesting? |
nineteendo commentedApr 1, 2024
Is there anything you still expect from me? Or can this finally be merged? I've listened to basically all the feedback. |
nineteendo commentedApr 1, 2024
The speed improvements seem way less impressive now. ;( |
nineteendo commentedApr 1, 2024
Are you happy now? |
Uh oh!
There was an error while loading.Please reload this page.
AlexWaygood commentedApr 2, 2024
I re-ran your benchmarks locally. With the latest version of your PR, I'm getting a reasonableslowdown on On With your PR branch: |
nineteendo commentedApr 2, 2024
You don't have a usb stick "2GB_001" plugged in, so the function will return |
AlexWaygood commentedApr 2, 2024
heh, that makes sense |
AlexWaygood left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM
nineteendo commentedApr 2, 2024
I've updated the benchmarks. Sadly, the only noticeable speedup for regular users is calling |
AlexWaygood commentedApr 2, 2024
Don't be too disheartened. As a result of your efforts here, a conversation has been started about possible ways of optimising Optimising the stdlib is hard! I tried outmany things that ultimately didn't work when I was working on#74690. And there were several things thatdid work, but which I never created PRs for, as they would have made the code too ugly or too fragile. My advice for the future, however, would definitely be to work on small, focused PRs that have isolated, easily measurable changes. PRs like that are much easier for us to review, and you should find the contributing experience less frustrating as a result. |
nineteendo commentedApr 2, 2024
Can this be merged, or are we still waiting on something? |
AlexWaygood commentedApr 2, 2024
It can be merged, I just wanted to wait a little bit longer to give the other reviewers time to chime in on the final version of the PR, if they wanted to. I'll merge tomorrow or the day after if there are no further objections from anybody. |
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
… into speedup-os.path
os.path functionsAlexWaygood commentedApr 2, 2024
Thanks@nineteendo |
serhiy-storchaka left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
erlend-aasland commentedApr 3, 2024
Both cases were significantly improved by#117466: I think we should be careful about micro-optimising Python code, like this PR. Instead, it would be better to keep the code as idiomatic as possible, and instead optimise the Python interpreter for the idiomatic cases. |
Uh oh!
There was an error while loading.Please reload this page.
AlexWaygood commentedApr 3, 2024
I agree that we should neither accept micro-optimisations that make code significantly less idiomatic, nor changes that are purely cosmetic and have no impact on performance. I accepted the PR nonetheless because in the final iteration of the PR, all changes seemed to me to be small, localised changes that, as well as providing small speedups, mostly made the code more idiomatic, and in all cases (in my opinion) did not cause a significant deterioration in style. |
nineteendo commentedApr 3, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I didn't expect the second case to be sped up as it was a sequence, so I asked for clarification:faster-cpython/ideas#671 (comment), but didn't get a response. This speedup must have been added afterwards, which I missed. |
Uh oh!
There was an error while loading.Please reload this page.
Benchmarks
ntpath.py
script
posixpath.py
script
os.path#117349