Skip to content

Commit

Permalink
Optimize _query_var for str objects (#1131)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Sep 8, 2024
1 parent 7d61055 commit 0cfca85
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/1131.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improved performance of processing query string changes when arguments are :class:`str` -- by :user:`bdraco`.
4 changes: 2 additions & 2 deletions yarl/_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ def _query_seq_pairs(
@staticmethod
def _query_var(v: QueryVariable) -> str:
cls = type(v)
if issubclass(cls, str):
if cls is str or issubclass(cls, str):
if TYPE_CHECKING:
assert isinstance(v, str)
return v
Expand All @@ -1171,7 +1171,7 @@ def _query_var(v: QueryVariable) -> str:
if math.isnan(v):
raise ValueError("float('nan') is not supported")
return str(float(v))
if issubclass(cls, int) and cls is not bool:
if cls is not bool and issubclass(cls, int):
if TYPE_CHECKING:
assert isinstance(v, int)
return str(int(v))
Expand Down

0 comments on commit 0cfca85

Please sign in to comment.