mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
gh-128982: Substitute regular expression in http.cookiejar.join_header_words
for an efficient alternative (GH-128983)
The function does not anymore rely on a regular expression to find alphanumeric characters and underscores.
This commit is contained in:
parent
64ccbbbf36
commit
56e1900681
2 changed files with 3 additions and 1 deletions
|
@ -448,7 +448,7 @@ def join_header_words(lists):
|
|||
attr = []
|
||||
for k, v in pairs:
|
||||
if v is not None:
|
||||
if not re.search(r"^\w+$", v):
|
||||
if not v.isalnum() and '_' not in v:
|
||||
v = HEADER_JOIN_ESCAPE_RE.sub(r"\\\1", v) # escape " and \
|
||||
v = '"%s"' % v
|
||||
k = "%s=%s" % (k, v)
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Improve the performance of :func:`!http.cookiejar.join_header_words` by up
|
||||
to 35%. Patch by Bénédikt Tran.
|
Loading…
Add table
Add a link
Reference in a new issue