Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-114847: Speed upposixpath.realpath()#114848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
barneygale merged 23 commits intopython:mainfrombarneygale:gh-114847
Apr 5, 2024
Merged
Changes from1 commit
Commits
Show all changes
23 commits
Select commitHold shift + click to select a range
0a4f60a
GH-114847: Speed up `posixpath.realpath()`
barneygaleFeb 1, 2024
5aa9c51
Tiny tweak
barneygaleFeb 1, 2024
b758710
Slightly speed up handling of empty/dot parts
barneygaleFeb 1, 2024
eb079b4
Merge branch 'main' into gh-114847
barneygaleMar 31, 2024
60d3bcb
Simplify '..' handling.
barneygaleMar 31, 2024
b849308
A few more perf improvements and simplifications.
barneygaleMar 31, 2024
085e105
Simplify symlink resolution signalling
barneygaleMar 31, 2024
69dabd2
Tiny tweaks
barneygaleMar 31, 2024
197c871
Spacing
barneygaleMar 31, 2024
b03e474
Merge branch 'main' into gh-114847
barneygaleApr 1, 2024
ecd1fe7
Comments
barneygaleApr 1, 2024
4b83c97
Final tweaks
barneygaleApr 1, 2024
77712d2
Further explain 'rest'.
barneygaleApr 1, 2024
15199a8
Update Lib/posixpath.py
barneygaleApr 2, 2024
8b3b808
Merge branch 'main' into gh-114847
barneygaleApr 2, 2024
01127e3
Merge branch 'main' into gh-114847
barneygaleApr 3, 2024
31955ee
Undo re-ordering of lstat() and seen lookup
barneygaleApr 3, 2024
211167e
Merge branch 'main' into gh-114847
barneygaleApr 3, 2024
fe62fef
Re-optimise link check
barneygaleApr 4, 2024
ebccd2b
Stop querying when `lstat()` fails.
barneygaleApr 4, 2024
d2a0248
Keep querying if we hit an OSError from lstat()
barneygaleApr 4, 2024
ecbb27c
Merge branch 'main' into gh-114847
barneygaleApr 4, 2024
eed739a
Update Lib/posixpath.py
barneygaleApr 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Undo re-ordering of lstat() and seen lookup
  • Loading branch information
@barneygale
barneygale committedApr 3, 2024
commit31955eead612107c8ec350fac8a5f8a03349ffe6
28 changes: 13 additions & 15 deletionsLib/posixpath.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -454,6 +454,17 @@ def realpath(filename, *, strict=False):
if not querying:
path = newpath
continue
try:
st = os.lstat(newpath)
except OSError:
if strict:
raise
is_link = False
else:
is_link = stat.S_ISLNK(st.st_mode)
if not is_link:
path = newpath
continue
# Resolve the symbolic link
if newpath in seen:
# Already seen this path
Expand All@@ -470,24 +481,11 @@ def realpath(filename, *, strict=False):
path = newpath
querying = False
continue
try:
st = os.lstat(newpath)
if not stat.S_ISLNK(st.st_mode):
path = newpath
continue
target = os.readlink(newpath)
except OSError:
if strict:
raise
else:
# Return already resolved part + rest of the path unchanged.
path = newpath
querying = False
continue
seen[newpath] = None # not resolved symlink
target = os.readlink(newpath)
if target.startswith(sep):
# Symlink target is absolute; reset resolved path.
path = sep
seen[newpath] = None # not resolved symlink
# Push the symlink path onto the stack, and signal its specialness by
# also pushing None. When these entries are popped, we'll record the
# fully-resolved symlink target in the 'seen' mapping.
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp