mirror of
https://github.com/python/cpython.git
synced 2025-07-23 19:25:40 +00:00
GH-113528: Deoptimise pathlib._abc.PurePathBase.relative_to()
(#113529)
Replace use of `_from_parsed_parts()` with `with_segments()` in `PurePathBase.relative_to()`, and move the assignment of `_drv`, `_root` and `_tail_cached` slots into `PurePath.relative_to()`.
This commit is contained in:
parent
37bd893a22
commit
a15a7735e6
2 changed files with 5 additions and 2 deletions
|
@ -371,7 +371,7 @@ class PurePathBase:
|
|||
else:
|
||||
raise ValueError(f"{str(self)!r} and {str(other)!r} have different anchors")
|
||||
parts = ['..'] * step + self._tail[len(path._tail):]
|
||||
return self._from_parsed_parts('', '', parts)
|
||||
return self.with_segments(*parts)
|
||||
|
||||
def is_relative_to(self, other):
|
||||
"""Return True if the path is relative to another path or False.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue