mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
GH-113225: Speed up pathlib.Path.glob()
(#113226)
Use `os.DirEntry.path` as the string representation of child paths, unless the parent path is empty, in which case we use the entry `name`.
This commit is contained in:
parent
4681a5271a
commit
c2e8298eba
2 changed files with 8 additions and 1 deletions
|
@ -301,7 +301,13 @@ class Path(_abc.PathBase, PurePath):
|
|||
|
||||
def _make_child_entry(self, entry):
|
||||
# Transform an entry yielded from _scandir() into a path object.
|
||||
return self._make_child_relpath(entry.name)
|
||||
path_str = entry.name if str(self) == '.' else entry.path
|
||||
path = self.with_segments(path_str)
|
||||
path._str = path_str
|
||||
path._drv = self.drive
|
||||
path._root = self.root
|
||||
path._tail_cached = self._tail + [entry.name]
|
||||
return path
|
||||
|
||||
def absolute(self):
|
||||
"""Return an absolute version of this path
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue