11import os
22from dataclasses import dataclass
3+ from functools import cache
34from pathlib import Path
45from typing import Any
56
@@ -32,6 +33,7 @@ def get_dependency_url(key: str, tag: str, platform: str) -> str:
3233 return url_template .replace ("{TAG}" , tag )
3334
3435
36+ @cache
3537def get_value (name : str ) -> str :
3638 _guard_valid_name (name )
3739 data = get_active ()
@@ -41,6 +43,7 @@ def get_value(name: str) -> str:
4143 return value
4244
4345
46+ @cache
4447def get_address_hrp () -> str :
4548 return get_value ("default_address_hrp" )
4649
@@ -146,14 +149,17 @@ def get_defaults() -> dict[str, Any]:
146149 }
147150
148151
152+ @cache
149153def get_proxy_url () -> str :
150154 return get_value ("proxy_url" )
151155
152156
157+ @cache
153158def get_explorer_url () -> str :
154159 return get_value ("explorer_url" )
155160
156161
162+ @cache
157163def get_confirmation_setting () -> bool :
158164 confirmation_value = get_value ("ask_confirmation" )
159165 if confirmation_value .lower () in ["true" , "yes" , "1" ]:
@@ -176,6 +182,7 @@ def resolve_config_path() -> Path:
176182 return GLOBAL_CONFIG_PATH
177183
178184
185+ @cache
179186def read_file () -> dict [str , Any ]:
180187 config_path = resolve_config_path ()
181188 if config_path .exists ():
@@ -210,6 +217,7 @@ class MxpyConfig:
210217 ask_confirmation : bool
211218
212219 @classmethod
220+ @cache
213221 def from_active_config (cls ) -> "MxpyConfig" :
214222 return cls (
215223 address_hrp = get_address_hrp (),
0 commit comments