diff options
author | Barney Gale <barney.gale@gmail.com> | 2024-04-13 23:08:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-13 23:08:03 (GMT) |
commit | a74f117dab369e6c54156c7b2256769fed0c23d0 (patch) | |
tree | 6db14d7a5be43aadca9df39cb304141f5322dcf8 /Doc | |
parent | 3095d026424f11714f0b7a828c61dc741d4e716b (diff) | |
download | cpython-a74f117dab369e6c54156c7b2256769fed0c23d0.zip cpython-a74f117dab369e6c54156c7b2256769fed0c23d0.tar.gz cpython-a74f117dab369e6c54156c7b2256769fed0c23d0.tar.bz2 |
GH-115060: Speed up `pathlib.Path.glob()` by omitting initial `stat()` (#117831)
Since 6258844c, paths that might not exist can be fed into pathlib's
globbing implementation, which will call `os.scandir()` / `os.lstat()` only
when strictly necessary. This allows us to drop an initial `self.is_dir()`
call, which saves a `stat()`.
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/pathlib.rst | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst index f4ed479..2e18e41 100644 --- a/Doc/library/pathlib.rst +++ b/Doc/library/pathlib.rst @@ -1004,10 +1004,6 @@ call fails (for example because the path doesn't exist). .. seealso:: :ref:`pathlib-pattern-language` documentation. - This method calls :meth:`Path.is_dir` on the top-level directory and - propagates any :exc:`OSError` exception that is raised. Subsequent - :exc:`OSError` exceptions from scanning directories are suppressed. - By default, or when the *case_sensitive* keyword-only argument is set to ``None``, this method matches paths using platform-specific casing rules: typically, case-sensitive on POSIX, and case-insensitive on Windows. @@ -1028,6 +1024,11 @@ call fails (for example because the path doesn't exist). .. versionchanged:: 3.13 The *pattern* parameter accepts a :term:`path-like object`. + .. versionchanged:: 3.13 + Any :exc:`OSError` exceptions raised from scanning the filesystem are + suppressed. In previous versions, such exceptions are suppressed in many + cases, but not all. + .. method:: Path.rglob(pattern, *, case_sensitive=None, recurse_symlinks=False) |