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

Optimize _query_var for str objects #1131

Merged
merged 9 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1154,7 +1154,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 @@ -1166,7 +1166,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
Loading