Commit ce63a668 authored by Yusei Tahara's avatar Yusei Tahara Committed by Xavier Thompson

[opti] buildout.py: Optimize _install_and_load by using cache

_install_and_load is slow, using cache saves time when there are
many sections.
parent c8c101a5
......@@ -1545,9 +1545,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)
......@@ -1574,8 +1581,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