mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +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
|
@ -245,7 +245,10 @@ class PurePath(_abc.PurePathBase):
|
|||
"scheduled for removal in Python 3.14")
|
||||
warnings.warn(msg, DeprecationWarning, stacklevel=2)
|
||||
other = self.with_segments(other, *_deprecated)
|
||||
return _abc.PurePathBase.relative_to(self, other, walk_up=walk_up)
|
||||
path = _abc.PurePathBase.relative_to(self, other, walk_up=walk_up)
|
||||
path._drv = path._root = ''
|
||||
path._tail_cached = path._raw_paths.copy()
|
||||
return path
|
||||
|
||||
def is_relative_to(self, other, /, *_deprecated):
|
||||
"""Return True if the path is relative to another path or False.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue