how much does caching help?

This commit is contained in:
Khaleel Al-Adhami 2025-02-14 15:15:50 -08:00
parent d399748cc3
commit 800b2df2c6

View File

@ -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: