GH-113225: Speed up pathlib._abc.PathBase.glob() (#113556)

`PathBase._scandir()` is implemented using `iterdir()`, so we can use its
results directly, rather than passing them through `_make_child_relpath()`.
This commit is contained in:
Barney Gale 2023-12-28 22:23:01 +00:00 committed by GitHub
parent db1c882239
commit b664d91599
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View file

@ -299,6 +299,10 @@ class Path(_abc.PathBase, PurePath):
def _scandir(self):
return os.scandir(self)
def _make_child_entry(self, entry):
# Transform an entry yielded from _scandir() into a path object.
return self._make_child_relpath(entry.name)
def absolute(self):
"""Return an absolute version of this path
No normalization or symlink resolution is performed.