cache the inner _get_component_prop_names
This commit is contained in:
parent
f1c95aa723
commit
0a2be4b74e
@ -693,6 +693,21 @@ class Component(BaseComponent, ABC):
|
|||||||
"""
|
"""
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@lru_cache(maxsize=None)
|
||||||
|
@classmethod
|
||||||
|
def _get_component_prop_names(cls) -> Set[str]:
|
||||||
|
"""Get the names of the component props. NOTE: This assumes all fields are known.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The names of the component props.
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
name
|
||||||
|
for name, field in cls.get_fields().items()
|
||||||
|
if name in cls.get_props()
|
||||||
|
and types._issubclass(field.outer_type_, Component)
|
||||||
|
}
|
||||||
|
|
||||||
def _get_components_in_props(self) -> Sequence[BaseComponent]:
|
def _get_components_in_props(self) -> Sequence[BaseComponent]:
|
||||||
"""Get the components in the props.
|
"""Get the components in the props.
|
||||||
|
|
||||||
@ -700,13 +715,11 @@ class Component(BaseComponent, ABC):
|
|||||||
The components in the props.
|
The components in the props.
|
||||||
"""
|
"""
|
||||||
if self._are_fields_known():
|
if self._are_fields_known():
|
||||||
return tuple(
|
return [
|
||||||
component
|
component
|
||||||
for name, field in self.get_fields().items()
|
for name in self._get_component_prop_names()
|
||||||
if name in self.get_props()
|
|
||||||
and types._issubclass(field.outer_type_, Component)
|
|
||||||
for component in _components_from(getattr(self, name))
|
for component in _components_from(getattr(self, name))
|
||||||
)
|
]
|
||||||
return [
|
return [
|
||||||
component
|
component
|
||||||
for prop in self.get_props()
|
for prop in self.get_props()
|
||||||
|
Loading…
Reference in New Issue
Block a user