Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Speed uppathlib.Path.glob() by removing redundant regex matching #115060

Closed
@barneygale

Description

@barneygale

In#104512 we madepathlib.Path.glob() use a "walk-and-filter" strategy for expanding** wildcards in patterns: when we encounter a** segment, we immediately consume subsequent segments and use them to build a regex that is used to filter results. This saves a bunch ofscandir() calls.

However! We actually build a regex for theentire pattern given toglob(), rather than just the segments following** wildcards. And so when evaluating a pattern likedir*/**/file*, thedir* part is needlessly matched twice against each path.@zooba noted this in areview comment at the time.

We should be able to improve performance by building anre.Pattern only for segments following** wildcards, and not the entireglob() pattern.

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp