perf: use os.path.abspath() instead of Path.resolve()#10821
Draft
radoering wants to merge 1 commit intopython-poetry:mainfrom
Draft
perf: use os.path.abspath() instead of Path.resolve()#10821radoering wants to merge 1 commit intopython-poetry:mainfrom
os.path.abspath() instead of Path.resolve()#10821radoering wants to merge 1 commit intopython-poetry:mainfrom
Conversation
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.
Pull Request Check List
There is a significant performance regression due to #10792, which is mostly caused by the two calls of
Path.resolve().The time to install a sample project with some dependencies increased from 8 seconds (Poetry 2.3.2) to 13 seconds (Poetry 2.3.3).
With the fix, installation is almost as fast as before (less than half a second slower).
It should be safe to use
os.path.abspath()instead ofPath.resolve(). At least, I could not craft a wheel that triggers a path traversal via symlinks (see new test). Further,os.path.abspath()is recommended in https://docs.python.org/3/library/zipfile.html#zipfile.Path and (if I do not miss anything) pip also usesos.path.abspath()(and notPath.resolve()): https://github.com/pypa/pip/blob/8c5468dc9695c023c0a6428e630126aa14c9db4e/src/pip/_internal/utils/unpacking.py#L79-L87