From 6fe931ccb1bfd9cbd17db167778517600b3857ce Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Fri, 5 Feb 2021 23:27:05 -0800 Subject: [PATCH] spec performance: don't parse in from_node_dict Constructing a spec from a name instead of setting name directly forces from_node_dict to call Spec.parse(), which is slow. Avoid this by using a zero-arg constructor and setting name directly. --- lib/spack/spack/spec.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 06767d6c7d..985236bf6d 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -1786,10 +1786,12 @@ def from_node_dict(node): name = next(iter(node)) node = node[name] - spec = Spec(name, full_hash=node.get('full_hash', None)) + spec = Spec() + spec.name = name spec.namespace = node.get('namespace', None) spec._hash = node.get('hash', None) spec._build_hash = node.get('build_hash', None) + spec._full_hash = node.get('full_hash', None) if 'version' in node or 'versions' in node: spec.versions = vn.VersionList.from_dict(node)