mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00: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'..')
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue