mirror of https://github.com/python/cpython
gh-117394: Speed up os.path.ismount() on Posix (GH-117447)
It is now 2-3 times faster if the user has permissions.
This commit is contained in:
parent
51132da0c4
commit
4e502a4997
|
@ -206,11 +206,14 @@ def ismount(path):
|
|||
parent = join(path, b'..')
|
||||
else:
|
||||
parent = join(path, '..')
|
||||
parent = realpath(parent)
|
||||
try:
|
||||
s2 = os.lstat(parent)
|
||||
except (OSError, ValueError):
|
||||
return False
|
||||
except OSError:
|
||||
parent = realpath(parent)
|
||||
try:
|
||||
s2 = os.lstat(parent)
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
# path/.. on a different device as path or the same i-node as path
|
||||
return s1.st_dev != s2.st_dev or s1.st_ino == s2.st_ino
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
:func:`os.path.ismount` is now 2-3 times faster if the user has permissions.
|
Loading…
Reference in New Issue