You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The implementation of pathlib.Path.absolute() can call with_segments() with multiple arguments; the resulting path object will be internally unjoined and unparsed, making str(path.absolute()) slow, amongst other things.
absolute() already has most of the information it needs to produce paths that are pre-joined, and either pre-parsed (if the input has tail segments) or pre-stringified (otherwise). This could provide a tasty speedup.
Use `_from_parsed_parts()` to create a pre-joined/pre-parsed path, rather
than passing multiple arguments to `with_segments()`
Co-authored-by: Alex Waygood <[email protected]>
Use `_from_parsed_parts()` to create a pre-joined/pre-parsed path, rather
than passing multiple arguments to `with_segments()`
Co-authored-by: Alex Waygood <[email protected]>
Glyphack
pushed a commit
to Glyphack/cpython
that referenced
this issue
Sep 2, 2024
Use `_from_parsed_parts()` to create a pre-joined/pre-parsed path, rather
than passing multiple arguments to `with_segments()`
Co-authored-by: Alex Waygood <[email protected]>
The implementation of
pathlib.Path.absolute()
can callwith_segments()
with multiple arguments; the resulting path object will be internally unjoined and unparsed, makingstr(path.absolute())
slow, amongst other things.absolute()
already has most of the information it needs to produce paths that are pre-joined, and either pre-parsed (if the input has tail segments) or pre-stringified (otherwise). This could provide a tasty speedup.Linked PRs
pathlib.Path.absolute()
#112728The text was updated successfully, but these errors were encountered: