Speed up `pathlib.Path.glob()` by working with strings internally · Issue #117586 · python/cpython · GitHub
Skip to content

Speed up pathlib.Path.glob() by working with strings internally #117586

Description

@barneygale

pathlib.Path.glob() currently generates Path objects for intermediate paths that might never be yielded to the user, which is slow and unnecessary. For example, a pattern like **/*.mp3 is evaluated by creating a Path object for every directory visited.

There are already few tricks employed to avoid instantiation, but it would be better if only real results were converted to path objects.

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directorytopic-pathlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions