mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
gh-95865: Speed up urllib.parse.quote_from_bytes() (GH-95872)
This commit is contained in:
parent
88671a9d69
commit
8ba22b90ca
2 changed files with 2 additions and 1 deletions
|
|
@ -906,7 +906,7 @@ def quote_from_bytes(bs, safe='/'):
|
||||||
if not bs.rstrip(_ALWAYS_SAFE_BYTES + safe):
|
if not bs.rstrip(_ALWAYS_SAFE_BYTES + safe):
|
||||||
return bs.decode()
|
return bs.decode()
|
||||||
quoter = _byte_quoter_factory(safe)
|
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,
|
def urlencode(query, doseq=False, safe='', encoding=None, errors=None,
|
||||||
quote_via=quote_plus):
|
quote_via=quote_plus):
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
Speed up :func:`urllib.parse.quote_from_bytes` by replacing a list comprehension with ``map()``.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue