Commit 95fa0f3d authored by Yusei Tahara's avatar Yusei Tahara

buildout.py: Optimize _compute_part_signatures. Cache recipe signature and...

buildout.py: Optimize _compute_part_signatures. Cache recipe signature and calculate once per recipe.

Signature calculation is slow, so using cache saves a lot of time when the same recipe is used many times.
parent 11f54ea2
......@@ -918,14 +918,24 @@ class Buildout(DictMixin):
"Unexpected entry, %r, in develop-eggs directory.", f)
def _compute_part_signatures(self, parts):
# The same recipe may appear many times.
sig_cache= {}
# Compute recipe signature and add to options
for part in parts:
options = self.get(part)
if options is None:
options = self[part] = {}
recipe, entry = _recipe(options)
req = pkg_resources.Requirement.parse(recipe)
sig = sorted(set(_dists_sig(pkg_resources.working_set.resolve([req]))))
try:
# Copy cached list, because sig.append is called later
sig = sig_cache[recipe][:]
except KeyError:
req = pkg_resources.Requirement.parse(recipe)
sig_result = sig_cache[recipe] = sorted(set(_dists_sig(pkg_resources.working_set.resolve([req]))))
sig = sig_result[:]
for dependency in sorted(options.depends):
m = md5()
for item in sorted(self[dependency].items()):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment