]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-95865: Speed up urllib.parse.quote_from_bytes() (GH-95872)
authorDennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
Wed, 31 Aug 2022 01:39:51 +0000 (21:39 -0400)
committerGitHub <noreply@github.com>
Wed, 31 Aug 2022 01:39:51 +0000 (21:39 -0400)
Lib/urllib/parse.py
Misc/NEWS.d/next/Library/2022-08-11-03-16-48.gh-issue-95865.0IOkFP.rst [new file with mode: 0644]

index fd6d9f44c6268ccaa41461bf099988de804f7dd9..f25c770068bdd1cf4071dace6d559d4118938a0e 100644 (file)
@@ -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 (file)
index 0000000..aa7c73f
--- /dev/null
@@ -0,0 +1 @@
+Speed up :func:`urllib.parse.quote_from_bytes` by replacing a list comprehension with ``map()``.