From 800b2df2c6429fcd87f484acfc99f8e9611da5b7 Mon Sep 17 00:00:00 2001 From: Khaleel Al-Adhami <khaleel.aladhami@gmail.com> Date: Fri, 14 Feb 2025 15:15:50 -0800 Subject: [PATCH] how much does caching help? --- reflex/components/component.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/reflex/components/component.py b/reflex/components/component.py index 60214a81e..0f38f73f8 100644 --- a/reflex/components/component.py +++ b/reflex/components/component.py @@ -684,19 +684,20 @@ class Component(BaseComponent, ABC): """ return set() - def _get_components_in_props(self) -> Iterator[BaseComponent]: + @lru_cache(maxsize=None) # noqa: B019 + def _get_components_in_props(self) -> Sequence[BaseComponent]: """Get the components in the props. Yields: The components in the props. """ - yield from ( + return [ component for prop in self.get_props() if (value := getattr(self, prop)) is not None and isinstance(value, (BaseComponent, Var)) for component in _components_from(value) - ) + ] @classmethod def create(cls, *children, **props) -> Self: