mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 10:58:28 +00:00
Speed up version parsing for a 1.27±0.03 speedup in transformers-extras with conservative changes (#660)
Two low-hanging fruits as optimizations for version parsing: A fast path for release only versions and removing the regex from version specifiers (still calling into version's parsing regex if required). This enables optimizing the serde format since we now see the serde part instead of only PEP 440 parsing. I intentionally didn't rewrite the full PEP 440 at this step. ```console $ hyperfine --warmup 5 --runs 50 "target/profiling/puffin pip-compile scripts/requirements/transformers-extras.in" "target/profiling/main pip-compile scripts/requirements/transformers-extras.in" Benchmark 1: target/profiling/puffin pip-compile scripts/requirements/transformers-extras.in Time (mean ± σ): 217.1 ms ± 3.2 ms [User: 194.0 ms, System: 55.1 ms] Range (min … max): 211.0 ms … 228.1 ms 50 runs Benchmark 2: target/profiling/main pip-compile scripts/requirements/transformers-extras.in Time (mean ± σ): 276.7 ms ± 5.7 ms [User: 252.4 ms, System: 54.6 ms] Range (min … max): 268.9 ms … 303.5 ms 50 runs Summary target/profiling/puffin pip-compile scripts/requirements/transformers-extras.in ran 1.27 ± 0.03 times faster than target/profiling/main pip-compile scripts/requirements/transformers-extras.in ``` --------- Co-authored-by: Andrew Gallant <andrew@astral.sh>
This commit is contained in:
parent
305b9b080a
commit
620f73b38b
6 changed files with 74 additions and 42 deletions
|
@ -46,7 +46,7 @@ fn invalid_requirement() -> Result<()> {
|
|||
|
||||
----- stderr -----
|
||||
error: Failed to parse `flask==1.0.x`
|
||||
Caused by: Version specifier `==1.0.x` doesn't match PEP 440 rules
|
||||
Caused by: Version `1.0.x` doesn't match PEP 440 rules
|
||||
flask==1.0.x
|
||||
^^^^^^^
|
||||
"###);
|
||||
|
@ -93,7 +93,7 @@ fn invalid_requirements_txt_requirement() -> Result<()> {
|
|||
|
||||
----- stderr -----
|
||||
error: Couldn't parse requirement in requirements.txt position 0 to 12
|
||||
Caused by: Version specifier `==1.0.x` doesn't match PEP 440 rules
|
||||
Caused by: Version `1.0.x` doesn't match PEP 440 rules
|
||||
flask==1.0.x
|
||||
^^^^^^^
|
||||
"###);
|
||||
|
@ -207,7 +207,7 @@ dependencies = ["flask==1.0.x"]
|
|||
|
|
||||
3 | dependencies = ["flask==1.0.x"]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
Version specifier `==1.0.x` doesn't match PEP 440 rules
|
||||
Version `1.0.x` doesn't match PEP 440 rules
|
||||
flask==1.0.x
|
||||
^^^^^^^
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue