From 4a1e0235cc81442c312cb31a9ed5c639f0b1c8c5 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 10 Nov 2023 16:35:56 -0500 Subject: [PATCH] wrap: Cache get_releases() "meson wrap status" was calling it for each .wrap file. Better use lru_cache to ensure we don't make the same mistake elsewhere. --- mesonbuild/wrap/wrap.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index a5b4dc8ec..ea8b4bf61 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -35,6 +35,7 @@ import json from base64 import b64encode from netrc import netrc from pathlib import Path, PurePath +from functools import lru_cache from . import WrapMode from .. import coredata @@ -111,6 +112,7 @@ def get_releases_data(allow_insecure: bool) -> bytes: url = open_wrapdburl('https://wrapdb.mesonbuild.com/v2/releases.json', allow_insecure, True) return url.read() +@lru_cache(maxsize=None) def get_releases(allow_insecure: bool) -> T.Dict[str, T.Any]: data = get_releases_data(allow_insecure) return T.cast('T.Dict[str, T.Any]', json.loads(data.decode()))