_platform/platform.py: Cache result from 'get_host_os' 'get_host_os' is an expensive method and is called twice per element. Caching gives us some performance benefits.
diff --git a/src/buildstream/_platform/platform.py b/src/buildstream/_platform/platform.py index ca5fb75..02e8924 100644 --- a/src/buildstream/_platform/platform.py +++ b/src/buildstream/_platform/platform.py
@@ -32,6 +32,7 @@ class Platform(): _host_arch = None # cache to not recompute the host arch every time + _host_os = None # cache not to recompute the host os every time # Platform() # @@ -122,9 +123,11 @@ else: return min(cpu_count, cap) - @staticmethod - def get_host_os(): - return platform.uname().system + @classmethod + def get_host_os(cls): + if cls._host_os is None: + cls._host_os = platform.uname().system + return cls._host_os # canonicalize_arch(): #