8000 Speed up config.__getattr__ with a factor 10 corresponding to 5-10% app speed up. by MarcSkovMadsen · Pull Request #5851 · holoviz/panel · GitHub
[go: up one dir, main page]

Skip to content
Prev Previous commit
Next Next commit
improve
  • Loading branch information
MarcSkovMadsen committed Nov 11, 2023
commit ece3e8a714f85546a5403dbfccc3da31c197cefb
12 changes: 9 additions & 3 deletions panel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
from collections import defaultdict

ATTRS = defaultdict(lambda: 0)
_PARAMS = None

def validate_config(config, parameter, value):
"""
Expand Down Expand Up @@ -450,10 +451,15 @@ def __getattribute__(self, attr):
if attr=="param":
return super().__getattribute__(attr)

global _PARAMS
if not _PARAMS and init:
_PARAMS = set(super().__getattribute__('param'))

if init and not attr.startswith('__'):
params = set(super().__getattribute__('param'))
_params=_PARAMS
else:
params = []
_params = {}

session_config = super().__getattribute__('_session_config')
curdoc = state.curdoc
if curdoc and curdoc not in session_config:
Expand All @@ -466,7 +472,7 @@ def __getattribute__(self, attr):
return super().__getattribute__(attr)
elif curdoc and curdoc in session_config and attr in session_config[curdoc]:
return session_config[curdoc][attr]
elif f'_{attr}' in params and getattr(self, f'_{attr}_') is not None:
elif f'_{attr}' in _params and getattr(self, f'_{attr}_') is not None:
return super().__getattribute__(f'_{attr}_')
return super().__getattribute__(attr)

Expand Down
0