mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
GH-125413: pathlib ABCs: use scandir()
to speed up walk()
(#126262)
Use the new `PathBase.scandir()` method in `PathBase.walk()`, which greatly reduces the number of `PathBase.stat()` calls needed when walking. There are no user-facing changes, because the pathlib ABCs are still private and `Path.walk()` doesn't use the implementation in its superclass.
This commit is contained in:
parent
68a51e0178
commit
37651cfbce
2 changed files with 14 additions and 12 deletions
|
@ -1951,7 +1951,7 @@ class DummyPathTest(DummyPurePathTest):
|
|||
if self.can_symlink:
|
||||
# Add some symlinks
|
||||
source.joinpath('linkC').symlink_to('fileC')
|
||||
source.joinpath('linkD').symlink_to('dirD')
|
||||
source.joinpath('linkD').symlink_to('dirD', target_is_directory=True)
|
||||
|
||||
# Perform the copy
|
||||
target = base / 'copyC'
|
||||
|
@ -2969,7 +2969,7 @@ class DummyPathTest(DummyPurePathTest):
|
|||
f.write(f"I'm {path} and proud of it. Blame test_pathlib.\n")
|
||||
|
||||
if self.can_symlink:
|
||||
self.link_path.symlink_to(t2_path)
|
||||
self.link_path.symlink_to(t2_path, target_is_directory=True)
|
||||
broken_link_path.symlink_to('broken')
|
||||
broken_link2_path.symlink_to(self.cls('tmp3', 'broken'))
|
||||
self.sub2_tree = (self.sub2_path, [], ["broken_link", "broken_link2", "link", "tmp3"])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue