Speed up blib2to3
tokenization using generic python function
#4540
Labels
T: bug
Something isn't working
blib2to3
tokenization using generic python function
#4540
Describe the bug
is_fstring_start
usingbuiltin.any
for prefix matching is too slow and slows down fstring tokenization.To Reproduce
Run this minimal reproducing script:
The profiling output looks like this:
The
<genexpr>
inis_fstring_start
typically occupies around 15-20% of the time, which is too much and easily optimizable.Environment
Proposed Solution
change the
fstring_prefix
to a tuple and usetoken.startswith(fstring_prefix)
directlycc. @JelleZijlstra @tusharsadhwani
The text was updated successfully, but these errors were encountered: