Skip to content

perf: use os.path.abspath() instead of Path.resolve()#10821

Draft
radoering wants to merge 1 commit intopython-poetry:mainfrom
radoering:wheel-installer-perf-regression
Draft

perf: use os.path.abspath() instead of Path.resolve()#10821
radoering wants to merge 1 commit intopython-poetry:mainfrom
radoering:wheel-installer-perf-regression

Conversation

@radoering
Copy link
Copy Markdown
Member

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code.

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 of Path.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 uses os.path.abspath() (and not Path.resolve()): https://github.com/pypa/pip/blob/8c5468dc9695c023c0a6428e630126aa14c9db4e/src/pip/_internal/utils/unpacking.py#L79-L87

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant