Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34.3k
gh-146385: Switch back tore to detect shlex.quote slow path#146408
gh-146385: Switch back tore to detect shlex.quote slow path#146408bonzini wants to merge 1 commit intopython:mainfrom
re to detect shlex.quote slow path#146408Conversation
Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
python-cla-botbot commentedMar 25, 2026 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
picnixz commentedMar 25, 2026
@AA-Turner Can you check if the results are consistent on Windows as well please? |
picnixz commentedMar 25, 2026
Here is what I suggest:
I will also try to check what happens on older systems (openSUSE + older GCC/clang). |
Commit06a26fd ("pythongh-118761: Optimise import time for ``shlex`` (python#132036)")when the input has to be quoted. This is because the regular expressionsearch was able to short-circuit at the first unsafe character.Go back to the same algorithm as 3.13, but make the "import re" and compilationof the regular expression lazy.Testing s.isascii() makes shlex.quote() twice as fast in the non-ASCIIcase, but costs up to 25% of the full run time (because it necessitatesan earlier isinstance check) if the string *is* ASCII. The latter isprobably the common case, so drop the check.
Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
bonzini commentedMar 25, 2026
Yeah I didn't use |
picnixz commentedMar 25, 2026
For now, let's check whether the regression is consistent across platforms. |
bonzini commentedMar 25, 2026
It is, and also it's really a complexity change. |
picnixz commentedMar 25, 2026
What I want to know is why Adam reported numbers that went in the other direction. Ideally I also want to know the stdev of the numbers using |
picnixz commentedMar 25, 2026 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I suggested in#132036 (comment) to replace the
|
Uh oh!
There was an error while loading.Please reload this page.
Commit06a26fd ("gh-118761: Optimise import time for
shlex(#132036)") when the input has to be quoted. This is because the regular expression search was able to short-circuit at the first unsafe character.Go back to the same algorithm as 3.13, but make the "import re" and compilation of the regular expression lazy.
Testing
s.isascii()makesshlex.quote()twice as fast in the non-ASCII case, but costs up to 25% of the full run time (because it necessitates an earlierisinstancecheck) if the stringis ASCII. The latter is probably the common case, so drop the check.shlex.quotefrom 3.13 to 3.14 #146385