8000 GH-117586: Speed up `pathlib.Path.glob()` by working with strings by barneygale · Pull Request #117589 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-117586: Speed up pathlib.Path.glob() by working with strings #117589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More precise error handling
  • Loading branch information
barneygale committed Apr 6, 2024
commit 8696ca0583a1faaea0a0dec47aca56dbcefbab43
5 changes: 3 additions & 2 deletions Lib/glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ def select_wildcard(path, exists=False):
# avoid exhausting file descriptors when globbing deep trees.
with self.scandir(path) as scandir_it:
entries = list(scandir_it)
except OSError:
pass
else:
for entry in entries:
if match is None or match(entry.name):
if dir_only:
Expand All @@ -416,8 +419,6 @@ def select_wildcard(path, exists=False):
yield from select_next(entry_path, exists=True)
else:
yield entry_path
except OSError:
pass
return select_wildcard

def recursive_selector(self, part, parts):
Expand Down
0