Skip to content

Commit 4e502a4

Browse files
gh-117394: Speed up os.path.ismount() on Posix (GH-117447)
It is now 2-3 times faster if the user has permissions.
1 parent 51132da commit 4e502a4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Lib/posixpath.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,14 @@ def ismount(path):
206206
parent = join(path, b'..')
207207
else:
208208
parent = join(path, '..')
209-
parent = realpath(parent)
210209
try:
211210
s2 = os.lstat(parent)
212-
except (OSError, ValueError):
213-
return False
211+
except OSError:
212+
parent = realpath(parent)
213+
try:
214+
s2 = os.lstat(parent)
215+
except OSError:
216+
return False
214217

215218
# path/.. on a different device as path or the same i-node as path
216219
return s1.st_dev != s2.st_dev or s1.st_ino == s2.st_ino
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:func:`os.path.ismount` is now 2-3 times faster if the user has permissions.

0 commit comments

Comments
 (0)