mirror of
https://github.com/python/cpython
synced 2026-09-26 16:21:04 +03:00
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
2 changed files with 7 additions and 3 deletions
|
|
@ -206,11 +206,14 @@ def ismount(path):
|
||||||
parent = join(path, b'..')
|
parent = join(path, b'..')
|
||||||
else:
|
else:
|
||||||
parent = join(path, '..')
|
parent = join(path, '..')
|
||||||
parent = realpath(parent)
|
|
||||||
try:
|
try:
|
||||||
s2 = os.lstat(parent)
|
s2 = os.lstat(parent)
|
||||||
except (OSError, ValueError):
|
except OSError:
|
||||||
return False
|
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
|
# 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
|
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…
Add table
Add a link
Reference in a new issue