Skip to content

Commit 29160ac

Browse files
serhiy-storchakadiegorusso
authored andcommitted
pythongh-117394: Speed up os.path.ismount() on Posix (pythonGH-117447)
It is now 2-3 times faster if the user has permissions.
1 parent 7195565 commit 29160ac

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Lib/posixpath.py

Lines changed: 6 additions & 3 deletions
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
Lines changed: 1 addition & 0 deletions
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)