Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Improve performance of pathlib.Path.[is_]absolute() #103548

Closed
@barneygale

Description

@barneygale

Two optimizations are possible:

  • is_absolute() can pass the unnormalized path to os.path.isabs()
  • absolute() on an empty path (or Path.cwd()) can avoid joining an empty string onto the working directory (thus avoiding a call to os.path.join()), and short-circuit the string normalization (as the result of getcwd() is fully normalized)

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixesperformancePerformance or resource usagetopic-pathlibtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions