cpython/Lib/pathlib
Barney Gale cdca0ce0ad
GH-113528: Deoptimise pathlib._abc.PurePathBase.relative_to() (again) (#113882)
Restore full battle-tested implementations of `PurePath.[is_]relative_to()`. These were recently split up in 3375dfe and a15a773.

In `PurePathBase`, add entirely new implementations based on `_stack`, which itself calls `pathmod.split()` repeatedly to disassemble a path. These new implementations preserve features like trailing slashes where possible, while still observing that a `..` segment cannot be added to traverse an empty or `.` segment in *walk_up* mode. They do not rely on `parents` nor `__eq__()`, nor do they spin up temporary path objects.

Unfortunately calling `pathmod.relpath()` isn't an option, as it calls `abspath()` and in turn `os.getcwd()`, which is impure.
2024-01-09 23:04:14 +00:00
..
__init__.py GH-113528: Deoptimise pathlib._abc.PurePathBase.relative_to() (again) (#113882) 2024-01-09 23:04:14 +00:00
_abc.py GH-113528: Deoptimise pathlib._abc.PurePathBase.relative_to() (again) (#113882) 2024-01-09 23:04:14 +00:00