Skip to content

Commit

Permalink
Switch to using yarl.URL.absolute over yarl.URL.is_absolute() (#9171
Browse files Browse the repository at this point in the history
)
  • Loading branch information
bdraco authored Sep 18, 2024
1 parent dc6e692 commit 0462ae6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES/9171.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Improved performance of determining if a URL is absolute -- by :user:`bdraco`.

The property :attr:`~yarl.URL.absolute` is more performant than the method ``URL.is_absolute()`` and preferred when newer versions of yarl are used.
2 changes: 1 addition & 1 deletion aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def _build_url(self, str_or_url: StrOrURL) -> URL:
if self._base_url is None:
return url
else:
assert not url.is_absolute() and url.path.startswith("/")
assert not url.absolute and url.path.startswith("/")
return self._base_url.join(url)

async def _request(
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def make_url(self, path: StrOrURL) -> URL:
assert self._root is not None
url = URL(path)
if not self.skip_url_asserts:
assert not url.is_absolute()
assert not url.absolute
return self._root.join(url)
else:
return URL(str(self._root) + str(path))
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/web_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def __init__(
self._version = message.version
self._cache: Dict[str, Any] = {}
url = message.url
if url.is_absolute():
if url.absolute:
if scheme is not None:
url = url.with_scheme(scheme)
if host is not None:
Expand Down

0 comments on commit 0462ae6

Please sign in to comment.