Skip to content
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

Make raw_host and port cached_property #1044

Merged
merged 14 commits into from
Aug 19, 2024
3 changes: 3 additions & 0 deletions CHANGES/1044.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
``raw_host`` and ``port`` are now ``cached_property`` -- by :user:`bdraco`.

``aiohttp`` accesses these properties quite often, which cause ``urllib`` to build the ``_hostinfo`` property every time. ``raw_host`` and ``port`` are now cached properties, which will improve performance.
bdraco marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions yarl/_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ def password(self):
"""
return self._UNQUOTER(self.raw_password)

@property
@cached_property
bdraco marked this conversation as resolved.
Show resolved Hide resolved
def raw_host(self):
"""Encoded host part of URL.

Expand Down Expand Up @@ -549,7 +549,7 @@ def host(self):
return raw
return _idna_decode(raw)

@property
@cached_property
def port(self):
"""Port part of URL, with scheme-based fallback.

Expand Down
Loading