Improve performance of http.cookiejar.join_header_words
#128982
Open
Description
Feature or enhancement
Proposal:
Currently, we use if not re.search(r"^\w+$", v):
. This can be replaced by if not v.isalnum() and '_' not in v
. Benchmarks are as follows:
$ ./python -m pyperf timeit -s 'x = [[("text/plain", None), ("charset", "iso-8859-1\"")]]; from http.cookiejar import join_header_words as f' 'f(x)'
Mean +- std dev: [ref] 795 ns +- 8 ns -> [new] 604 ns +- 20 ns: 1.32x faster
It doesn't help having a compiled regex by the way.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response