From 1ea05cd456a773be4f46a5ef535893ab106b2d8b Mon Sep 17 00:00:00 2001 From: "Seth R. Johnson" Date: Mon, 11 Apr 2022 03:31:24 -0400 Subject: macos: fewer calls to sw_vers (#29997) In a typical call to spack, the OperatingSystem gets instantiated multiple times. For macOS, each one requires a call to `sw_vers`, which is done through the Executable helper class. Memoizing reduces the call count from "spac spec" from three to one. --- lib/spack/spack/operating_systems/mac_os.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib') diff --git a/lib/spack/spack/operating_systems/mac_os.py b/lib/spack/spack/operating_systems/mac_os.py index a150134618..403188262d 100644 --- a/lib/spack/spack/operating_systems/mac_os.py +++ b/lib/spack/spack/operating_systems/mac_os.py @@ -7,12 +7,15 @@ import os import platform as py_platform import re +import llnl.util.lang + from spack.util.executable import Executable from spack.version import Version from ._operating_system import OperatingSystem +@llnl.util.lang.memoized def macos_version(): """Get the current macOS version as a version object. @@ -59,6 +62,7 @@ def macos_version(): return Version(py_platform.mac_ver()[0]) +@llnl.util.lang.memoized def macos_cltools_version(): """Find the last installed version of the CommandLineTools. @@ -82,6 +86,7 @@ def macos_cltools_version(): return None +@llnl.util.lang.memoized def macos_sdk_path(): """Return path to the active macOS SDK. """ -- cgit v1.2.3-70-g09d2