From 5ec275fca2b8a1944c2b0a19ae4c334febd4929f Mon Sep 17 00:00:00 2001 From: Xavier Fernandez Date: Sat, 31 Oct 2020 16:00:11 +0100 Subject: [PATCH] Cache find_best_candidate results This is possible because self.make_candidate_evaluator only depends on: - the function arguments which are keys to the cache - self._target_python which never changes during a pip resolution - self._candidate_prefs which never changes during a pip resolution On a fresh install, pip install runs on my machine in: master (a0e34e9cf707c5) ======================= 0m33.058s 0m34.105s 0m32.426s This commit =========== 0m15.860s 0m16.254s 0m15.910s pip 20.2.4 - legacy resolver ============================ 0m15.145s 0m15.040s 0m15.152s --- src/pip/_internal/index/package_finder.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pip/_internal/index/package_finder.py b/src/pip/_internal/index/package_finder.py index b361e194d..9f39631dd 100644 --- a/src/pip/_internal/index/package_finder.py +++ b/src/pip/_internal/index/package_finder.py @@ -863,6 +863,7 @@ class PackageFinder(object): hashes=hashes, ) + @lru_cache(maxsize=None) def find_best_candidate( self, project_name, # type: str