mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
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>
This commit is contained in:
parent
3095d02642
commit
a74f117dab
6 changed files with 20 additions and 10 deletions
|
@ -8,6 +8,7 @@ import unittest
|
|||
from pathlib._abc import UnsupportedOperation, ParserBase, PurePathBase, PathBase
|
||||
import posixpath
|
||||
|
||||
from test.support import is_wasi
|
||||
from test.support.os_helper import TESTFN
|
||||
|
||||
|
||||
|
@ -1920,6 +1921,8 @@ class DummyPathTest(DummyPurePathTest):
|
|||
}
|
||||
self.assertEqual(given, {p / x for x in expect})
|
||||
|
||||
# See https://github.com/WebAssembly/wasi-filesystem/issues/26
|
||||
@unittest.skipIf(is_wasi, "WASI resolution of '..' parts doesn't match POSIX")
|
||||
def test_glob_dotdot(self):
|
||||
# ".." is not special in globs.
|
||||
P = self.cls
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue