mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 06:46:15 +00:00
Some performance optimizations after analyzing benchmarks. (#5841)
* Some performance optimizations after analyzing benchmarks. * add news fragment
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Add back some relevant caching to increase performance after the major refactor released with ``2023.8.19``
|
||||
+7
-1
@@ -3,6 +3,11 @@ import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
try:
|
||||
from functools import cached_property
|
||||
except ImportError:
|
||||
cached_property = property
|
||||
|
||||
|
||||
def _ensure_modules():
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
@@ -226,6 +231,7 @@ class Entry:
|
||||
return marker_str
|
||||
return None
|
||||
|
||||
@cached_property
|
||||
def get_cleaned_dict(self):
|
||||
self.validate_constraints()
|
||||
if self.entry.extras != self.lockfile_entry.extras:
|
||||
@@ -550,7 +556,7 @@ def clean_results(results, resolver, project, category):
|
||||
reverse_deps=reverse_deps,
|
||||
category=category,
|
||||
)
|
||||
entry_dict = translate_markers(entry.get_cleaned_dict())
|
||||
entry_dict = translate_markers(entry.get_cleaned_dict)
|
||||
new_results.append(entry_dict)
|
||||
return new_results
|
||||
|
||||
|
||||
@@ -326,19 +326,24 @@ class Resolver:
|
||||
alt_index_lookup[req_name] = index_mapping[index]
|
||||
return alt_index_lookup
|
||||
|
||||
@property
|
||||
def finder(self):
|
||||
@cached_property
|
||||
def package_finder(self):
|
||||
finder = get_package_finder(
|
||||
install_cmd=self.pip_command,
|
||||
options=self.pip_options,
|
||||
session=self.session,
|
||||
)
|
||||
return finder
|
||||
|
||||
@property
|
||||
def finder(self):
|
||||
finder = self.package_finder
|
||||
index_lookup = self.prepare_index_lookup()
|
||||
finder._link_collector.index_lookup = index_lookup
|
||||
finder._link_collector.search_scope.index_lookup = index_lookup
|
||||
return finder
|
||||
|
||||
@property
|
||||
@cached_property
|
||||
def parsed_constraints(self):
|
||||
pip_options = self.pip_options
|
||||
pip_options.extra_index_urls = []
|
||||
@@ -434,9 +439,10 @@ class Resolver:
|
||||
yield resolver
|
||||
|
||||
def resolve(self):
|
||||
constraints = self.constraints
|
||||
with temp_environ(), self.get_resolver() as resolver:
|
||||
try:
|
||||
results = resolver.resolve(self.constraints, check_supported_wheels=False)
|
||||
results = resolver.resolve(constraints, check_supported_wheels=False)
|
||||
except InstallationError as e:
|
||||
raise ResolutionFailure(message=str(e))
|
||||
else:
|
||||
@@ -512,6 +518,7 @@ class Resolver:
|
||||
return {self.project.get_hash_from_link(self.hash_cache, link)}
|
||||
return set()
|
||||
|
||||
@cached_property
|
||||
def resolve_hashes(self):
|
||||
if self.results is not None:
|
||||
for ireq in self.results:
|
||||
@@ -612,7 +619,7 @@ def actually_resolve_deps(
|
||||
category,
|
||||
)
|
||||
resolver.resolve()
|
||||
hashes = resolver.resolve_hashes()
|
||||
hashes = resolver.resolve_hashes
|
||||
resolver.resolve_constraints()
|
||||
results = resolver.clean_results()
|
||||
for warning in warning_list:
|
||||
|
||||
Reference in New Issue
Block a user