Commit 00169db5 authored by Yusei Tahara's avatar Yusei Tahara Committed by Xavier Thompson

buildout.py: Optimize _install_and_load by using cache.

_install_and_load is slow, using cache saves time when there are many sections.
parent 2e499199
......@@ -1333,9 +1333,16 @@ class Buildout(DictMixin):
def __len__(self):
return len(self._raw)
_install_and_load_cache = {}
def _install_and_load(spec, group, entry, buildout):
__doing__ = 'Loading recipe %r.', spec
key = spec, group, entry
try:
return _install_and_load_cache[key]
except KeyError:
pass
try:
req = pkg_resources.Requirement.parse(spec)
......@@ -1362,8 +1369,9 @@ def _install_and_load(spec, group, entry, buildout):
)
__doing__ = 'Loading %s recipe entry %s:%s.', group, spec, entry
return pkg_resources.load_entry_point(
result = _install_and_load_cache[key] = pkg_resources.load_entry_point(
req.project_name, group, entry)
return result
except Exception:
v = sys.exc_info()[1]
......
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