diff --git a/detect_host_arch.py b/detect_host_arch.py index 7669d9ec88..266b457bf7 100755 --- a/detect_host_arch.py +++ b/detect_host_arch.py @@ -4,10 +4,12 @@ # found in the LICENSE file. """Outputs host CPU architecture in format recognized by gyp.""" +from functools import lru_cache import platform import re +@lru_cache(maxsize=None) def HostArch(): """Returns the host architecture with a predictable string.""" host_arch = platform.machine().lower() diff --git a/tests/detect_host_arch_test.py b/tests/detect_host_arch_test.py index f3e8ebaa06..f5a8bda174 100644 --- a/tests/detect_host_arch_test.py +++ b/tests/detect_host_arch_test.py @@ -47,6 +47,7 @@ class DetectHostArchTest(unittest.TestCase): platform.machine.return_value = machine platform.processor.return_value = processor platform.architecture.return_value = arch + detect_host_arch.HostArch.cache_clear() self.assertEqual(expected, detect_host_arch.HostArch())