10000 GH-101362: Optimise PurePath(PurePath(...)) by barneygale · Pull Request #101667 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-101362: Optimise PurePath(PurePath(...)) #101667

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

8000
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
  • Loading branch information
barneygale and AlexWaygood authored Mar 5, 2023
commit 37be0837b8be06eeacd34822bb663ae7be81d7f7
3 changes: 2 additions & 1 deletion Doc/library/pathlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ we also call *flavours*:

Each element of *pathsegments* can be either a string representing a
path segment, or an object implementing the :class:`os.PathLike` interface
which returns a string, such as another path object::
where the :meth:`~os.PathLike.__fspath__` method returns a string,
such as another path object::

>>> PurePath('foo', 'some/path', 'bar')
PurePosixPath('foo/some/path/bar')
Expand Down
3 changes: 1 addition & 2 deletions Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,7 @@ def _parse_parts(cls, parts):
else:
raise TypeError(
"argument should be a str object or an os.PathLike "
"object returning str, not %r"
% type(path))
f"object where __fspath__ returns a str, not {type(path)!r}")
if altsep:
path = path.replace(altsep, sep)
drv, root, rel = cls._flavour.splitroot(path)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Speed up :class:`pathlib.PurePath` construction by handling arguments more
uniformly. When a path argument is supplied, we use its string
representation rather than joining its parts with :func:`os.path.join`.
uniformly. When a :class:`pathlib.Path argument is supplied,
we use its string representation rather than joining its parts
with :func:`os.path.join`.
0