Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: cache requires-python checks & skip debug logging
The `requires-python` check is pretty fast, but when performed for 10000 links, the checks consume a nontrival amount of time. For example, while installing (pre-cached + --dry-run) a pared down list of homeassistant dependencies (117 in total), link evaluation took 15% of the total runtime, with check_requires_python() accounting for half (7.5%) of that. The cache can be kept pretty small as `requires-python` specifiers often repeat, and when they do change, it's often in chunks (or between entirely different packages). For example, setuptools has like 1500 links, but only ~30 different `requires-python` specifiers. In addition, _log_skipped_link() is a hot method and unfortunately expensive as it hashes the link on every call. Fortunately, we can return early when debug logging is not enabled. In the same homeassistant run, this saves 0.7% of the runtime.
- Loading branch information