Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
GH-103548: Improve performance ofpathlib.Path.[is_]absolute()#103549
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from6 commits
871dbdb72c665237153c5e2558bb6e984bc7d1ebe2cfe99fd12957bfb476ce6b32b86cFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -664,7 +664,7 @@ def is_absolute(self): | ||
| # ntpath.isabs() is defective - see GH-44626 . | ||
| if self._flavour is ntpath: | ||
| return bool(self.drive and self.root) | ||
AlexWaygood marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| return self._flavour.isabs(self._raw_path) | ||
| def is_reserved(self): | ||
| """Return True if the path contains one of the special names reserved | ||
| @@ -873,6 +873,10 @@ def absolute(self): | ||
| cwd = self._flavour.abspath(self.drive) | ||
| else: | ||
| cwd = os.getcwd() | ||
| if not self.root and not self._tail: | ||
AlexWaygood marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| path = self.with_segments(cwd) | ||
| path._str = cwd # Fully normalized string from getcwd(). | ||
| return path | ||
AlexWaygood marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| return self.with_segments(cwd, self) | ||
| def resolve(self, strict=False): | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Improve performance of:meth:`pathlib.PurePath.is_absolute` and | ||
AlexWaygood marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| :meth:`pathlib.Path.absolute` by working with unnormalized paths and | ||
| avoiding unnecessary joining. | ||