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-114847: Speed upposixpath.realpath()#114848
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
Apply the following optimizations to `posixpath.realpath()`:- Remove use of recursion- Directly construct child paths rather than using `join()`- Use `os.getcwd[b]()` rather than `abspath()`- Use `startswith(sep)` rather than `isabs()`
barneygale commentedApr 1, 2024
I've added a few wordy comments because:
Hopefully it's a bit easier for the next person to grok with the comments in place. |
gpshead 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.
I like that this gets rid of recursion.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Petr Viktorin <encukou@gmail.com>
barneygale commentedApr 3, 2024
Given that symlinks are rare, perhaps I've actually slowed things down by checking in |
encukou commentedApr 4, 2024
The introduction of a Given a directory and a link to it: with Python 3.12 I get: With this PR: The previous behaviour matches coreutils: |
encukou commentedApr 5, 2024
Thanks. I see the other use of Guess that's one bug we need to let live. |
encukou 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, thank you!
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Petr Viktorin <encukou@gmail.com>
barneygale commentedApr 5, 2024
Thank you for the reviews! |
barneygale commentedApr 6, 2024
(For posterity:) I opened an issue about this:#117546 |
Apply the following optimizations to `posixpath.realpath()`:- Remove use of recursion- Construct child paths directly rather than using `join()`- Use `os.getcwd[b]()` rather than `abspath()`- Use `startswith(sep)` rather than `isabs()`- Use slicing rather than `split()`Co-authored-by: Petr Viktorin <encukou@gmail.com>
Uh oh!
There was an error while loading.Please reload this page.
Apply the following optimizations to
posixpath.realpath():join()os.getcwd[b]()rather thanabspath()startswith(sep)rather thanisabs()split()posixpath.realpath()#114847