Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve responsiveness when invoked via Python (astral-sh#9315)
This saves a handful of milliseconds on Windows and even more on other platforms when running `python -m ruff`. On non-Windows systems the process is replaced directly (impossible on Windows unfortunately). ``` ❯ docker run --rm python:3.11 bash -c "for i in {1..15}; do python -m timeit -n 1 -r 1 'from pathlib import Path'; done" 1 loop, best of 1: 25.7 msec per loop 1 loop, best of 1: 3.07 msec per loop 1 loop, best of 1: 3.16 msec per loop 1 loop, best of 1: 3.06 msec per loop 1 loop, best of 1: 3.32 msec per loop 1 loop, best of 1: 3.93 msec per loop 1 loop, best of 1: 3.26 msec per loop 1 loop, best of 1: 3.73 msec per loop 1 loop, best of 1: 3.1 msec per loop 1 loop, best of 1: 3.29 msec per loop 1 loop, best of 1: 3.12 msec per loop 1 loop, best of 1: 3.05 msec per loop 1 loop, best of 1: 3.04 msec per loop 1 loop, best of 1: 3.19 msec per loop 1 loop, best of 1: 3.04 msec per loop ❯ docker run --rm python:3.11 bash -c "for i in {1..15}; do python -m timeit -n 1 -r 1 'import subprocess'; done" 1 loop, best of 1: 31.2 msec per loop 1 loop, best of 1: 3.75 msec per loop 1 loop, best of 1: 4.71 msec per loop 1 loop, best of 1: 3.88 msec per loop 1 loop, best of 1: 4.08 msec per loop 1 loop, best of 1: 4.35 msec per loop 1 loop, best of 1: 3.94 msec per loop 1 loop, best of 1: 4.06 msec per loop 1 loop, best of 1: 3.88 msec per loop 1 loop, best of 1: 3.85 msec per loop 1 loop, best of 1: 3.84 msec per loop 1 loop, best of 1: 4.01 msec per loop 1 loop, best of 1: 4.21 msec per loop 1 loop, best of 1: 4.07 msec per loop 1 loop, best of 1: 4.11 msec per loop ❯ python -m timeit -n 1 -r 1 "from pathlib import Path" 1 loop, best of 1: 5.25 msec per loop ❯ python -m timeit -n 1 -r 1 "import subprocess" 1 loop, best of 1: 7.61 msec per loop ```
- Loading branch information