Skip to content

Commit

Permalink
Make raw_host and port cached_property (#1044)
Browse files Browse the repository at this point in the history
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <webknjaz@redhat.com>
  • Loading branch information
bdraco and webknjaz authored Aug 19, 2024
1 parent 5e3d895 commit f0e2d8a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
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 :mod:`urllib` to build the ``_hostinfo`` property every time. ``raw_host`` and ``port`` are now cached properties, which will improve performance.
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
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

0 comments on commit f0e2d8a

Please sign in to comment.