Skip to content

Commit

Permalink
Improve performance of URL equality checks (#1315)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Oct 17, 2024
1 parent 96649e7 commit 052215c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/1315.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improved performance of :class:`~yarl.URL` equality checks -- by :user:`bdraco`.
6 changes: 4 additions & 2 deletions yarl/_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,13 @@ def __eq__(self, other: object) -> bool:

val1 = self._val
if not val1.path and val1.netloc:
val1 = val1._replace(path="/")
scheme, netloc, _, query, fragment = val1
val1 = tuple.__new__(SplitResult, (scheme, netloc, "/", query, fragment))

val2 = other._val
if not val2.path and val2.netloc:
val2 = val2._replace(path="/")
scheme, netloc, _, query, fragment = val2
val2 = tuple.__new__(SplitResult, (scheme, netloc, "/", query, fragment))

return val1 == val2

Expand Down

0 comments on commit 052215c

Please sign in to comment.