◐ Shell
clean mode source ↗

GH-125413: Add `pathlib.Path.scandir()` method by barneygale · Pull Request #126060 · python/cpython

Add `pathlib.Path.scandir()` as a trivial wrapper of `os.scandir()`.

In the private `pathlib._abc.PathBase` class, we can rework the
`iterdir()`, `glob()`, `walk()` and `copy()` methods to call `scandir()`
and make use of cached directory entry information, and thereby improve
performance. Because the `Path.copy()` method is provided by `PathBase`,
this also speeds up traversal when copying local files and directories.
I'll save these for another PR.

ncoghlan

picnixz pushed a commit to picnixz/cpython that referenced this pull request

Dec 8, 2024
Add `pathlib.Path.scandir()` as a trivial wrapper of `os.scandir()`. This
will be used to implement several `PathBase` methods more efficiently,
including methods that provide `Path.copy()`.

ebonnal pushed a commit to ebonnal/cpython that referenced this pull request

Jan 12, 2025
Add `pathlib.Path.scandir()` as a trivial wrapper of `os.scandir()`. This
will be used to implement several `PathBase` methods more efficiently,
including methods that provide `Path.copy()`.