-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This speeds up a representative pip-compile by about 40% ``` λ hyperfine -w 1 -M 3 -p 'rm req.txt || true' 'python -m piptools compile req.in --output-file req.txt --strip-extras --resolver=backtracking' Benchmark 1: python -m piptools compile req.in --output-file req.txt --strip-extras --resolver=backtracking Time (mean ± σ): 28.552 s ± 2.552 s [User: 20.477 s, System: 1.547 s] Range (min … max): 26.446 s … 31.390 s 3 runs λ hyperfine -w 1 -M 3 -p 'rm req.txt || true' 'python -m piptools compile req.in --output-file req.txt --strip-extras --resolver=backtracking' Benchmark 1: python -m piptools compile req.in --output-file req.txt --strip-extras --resolver=backtracking Time (mean ± σ): 17.570 s ± 0.450 s [User: 11.537 s, System: 1.345 s] Range (min … max): 17.095 s … 17.989 s 3 runs ``` This makes the set.isdisjoint operation done over here much cheaper: https://github.com/pypa/pip/blob/593b85f4a/src/pip/_internal/models/wheel.py#L92 The reason for this is because a Python usually has a lot of supported tags. The Python I used above has 2000 supported tags! Whereas a wheel usually only has one or two file tags. The CPython code will unfortunately iterate over all 2000 tags to check if there's a match. Only if the other collection is a set will CPython think to swap the operands to iterate over the shorter collection: https://github.com/python/cpython/blob/35963da40f/Objects/setobject.c#L1352
- Loading branch information
1 parent
593b85f
commit 91c4fc4
Showing
7 changed files
with
21 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters