Commit ee0fa8e7 authored by Yusei Tahara's avatar Yusei Tahara Committed by Julien Muchembled

buildout.py: Optimize _install_and_load by using cache.

_install_and_load is slow, using cache saves time when there are many sections.
parent 93369b04
......@@ -1341,9 +1341,15 @@ 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
try:
return _install_and_load_cache[(spec, group, entry)]
except KeyError:
pass
try:
req = pkg_resources.Requirement.parse(spec)
......@@ -1370,8 +1376,10 @@ 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 = pkg_resources.load_entry_point(
req.project_name, group, entry)
_install_and_load_cache[(spec, group, entry)] = result
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