8000 gh-100562: improve performance of `pathlib.Path.absolute()` by barneygale · Pull Request #100563 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-100562: improve performance of pathlib.Path.absolute() #100563

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 4 commits into from
Jan 5, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

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
Improve cwd() docstring, add comment.
  • Loading branch information
barneygale committed Dec 29, 2022
commit c71e3647f270ea0771c8f77e7e98b2e96cbdb388
8 changes: 5 additions & 3 deletions Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,9 +748,11 @@ def __exit__(self, t, v, tb):

@classmethod
def cwd(cls):
"""Return a new path pointing to the current working directory
(as returned by os.getcwd()).
"""
"""Return a new path pointing to the current working directory."""
# We call 'absolute()' rather than using 'os.getcwd()' directly to
# enable users to replace the implementation of 'absolute()' in a
# subclass and benefit from the new behaviour here. This works because
# os.path.abspath('.') == os.getcwd().
return cls().absolute()

@classmethod
Expand Down
0