Skip to content

Optimize pathlib.Path.absolute() #112727

Closed
Closed
@barneygale

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions