]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-114847: Speed up `posixpath.realpath()` (#114848)
authorBarney Gale <barney.gale@gmail.com>
Fri, 5 Apr 2024 12:35:01 +0000 (13:35 +0100)
committerGitHub <noreply@github.com>
Fri, 5 Apr 2024 12:35:01 +0000 (12:35 +0000)
commitabfa16b44bb9426312613893b6e193b02ee0304f
tree1056d6152eb26836e630e4a5974f7e2201aea6a1
parent9ceaee74db7da0e71042ab0b385d844e9f282adb
GH-114847: Speed up `posixpath.realpath()` (#114848)

Apply the following optimizations to `posixpath.realpath()`:

- Remove use of recursion
- Construct child paths directly rather than using `join()`
- Use `os.getcwd[b]()` rather than `abspath()`
- Use `startswith(sep)` rather than `isabs()`
- Use slicing rather than `split()`

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Lib/posixpath.py
Lib/test/test_posixpath.py
Misc/NEWS.d/next/Library/2024-02-01-08-09-20.gh-issue-114847.-JrWrR.rst [new file with mode: 0644]