From 8ba22b90cafdf83d26318905a021311c6932d2c0 Mon Sep 17 00:00:00 2001 From: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com> Date: Tue, 30 Aug 2022 21:39:51 -0400 Subject: gh-95865: Speed up urllib.parse.quote_from_bytes() (GH-95872) --- Lib/urllib/parse.py | 2 +- Misc/NEWS.d/next/Library/2022-08-11-03-16-48.gh-issue-95865.0IOkFP.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2022-08-11-03-16-48.gh-issue-95865.0IOkFP.rst diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py index fd6d9f4..f25c770 100644 --- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -906,7 +906,7 @@ def quote_from_bytes(bs, safe='/'): if not bs.rstrip(_ALWAYS_SAFE_BYTES + safe): return bs.decode() quoter = _byte_quoter_factory(safe) - return ''.join([quoter(char) for char in bs]) + return ''.join(map(quoter, bs)) def urlencode(query, doseq=False, safe='', encoding=None, errors=None, quote_via=quote_plus): diff --git a/Misc/NEWS.d/next/Library/2022-08-11-03-16-48.gh-issue-95865.0IOkFP.rst b/Misc/NEWS.d/next/Library/2022-08-11-03-16-48.gh-issue-95865.0IOkFP.rst new file mode 100644 index 0000000..aa7c73f --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-08-11-03-16-48.gh-issue-95865.0IOkFP.rst @@ -0,0 +1 @@ +Speed up :func:`urllib.parse.quote_from_bytes` by replacing a list comprehension with ``map()``. -- cgit v0.12