Skip to content

Optimize joining of pathlib.PurePath() arguments. #104996

Description

@barneygale

In Python 3.12, when multiple arguments are given to PurePath(), the initialiser calls os.path.join() to join them. This is reasonably slow. For Python 3.13 we can make it faster by:

  1. Deferring joining of arguments until strictly needed
  2. (Maybe) re-implementing os.path.join(), as pathlib did before gh-94909: fix joining of absolute and relative Windows paths in pathlib  #95450.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and 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