gh-95865: Speed up urllib.parse.quote_from_bytes() (GH-95872)

This commit is contained in:
Dennis Sweeney 2022-08-30 21:39:51 -04:00 committed by GitHub
parent 88671a9d69
commit 8ba22b90ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View 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):

View file

@ -0,0 +1 @@
Speed up :func:`urllib.parse.quote_from_bytes` by replacing a list comprehension with ``map()``.