4343"""
4444
4545
46+ # Cache for the Pixi path
47+ _pixi_path_cache : str | None = None
48+
49+
4650def get_config_file () -> Path :
4751 return Path .home () / ".config" / "pixi-kernel" / "config.toml"
4852
@@ -55,6 +59,10 @@ def get_default_pixi_path() -> Path:
5559
5660
5761def find_pixi_binary () -> Result [str , None ]:
62+ # Return cached result if available
63+ if _pixi_path_cache is not None :
64+ return Success (_pixi_path_cache )
65+
5866 # 1. Check if the Pixi binary is available in the system PATH
5967 pixi_path = shutil .which ("pixi" )
6068 if pixi_path is not None :
@@ -82,6 +90,11 @@ def find_pixi_binary() -> Result[str, None]:
8290
8391
8492async def has_compatible_pixi () -> Result [None , str ]:
93+ global _pixi_path_cache
94+
95+ if _pixi_path_cache is not None :
96+ return Success (None )
97+
8598 result = find_pixi_binary ()
8699
87100 if isinstance (result , Failure ):
@@ -100,6 +113,8 @@ async def has_compatible_pixi() -> Result[None, str]:
100113 minimum_version = "." .join (map (str , MINIMUM_PIXI_VERSION ))
101114 return Failure (PIXI_OUTDATED .format (minimum_version = minimum_version ))
102115
116+ # We found a compatible Pixi binary, cache it
117+ _pixi_path_cache = pixi_path
103118 return Success (None )
104119
105120
0 commit comments