Visitar URL original
Optimize `pathlib.Path.absolute()` · Issue #112727 · python/cpython · GitHub
Skip to content

Optimize pathlib.Path.absolute() #112727

Closed
Closed

Description

@barneygale

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.

Linked PRs

Activity

  1. added 2 commits that reference this issue on Dec 4, 2023
  2. added a commit that references this issue on Feb 11, 2024
  3. added a commit that references this issue on Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions