MCPcopy Create free account
hub / github.com/dot-agent/nextpy / compile_from

Method compile_from

nextpy/frontend/components/component.py:1681–1700  ·  view source on GitHub ↗

Walk through the component tree and memoize all stateful components. Args: component: The component to memoize. Returns: The memoized component tree.

(cls, component: BaseComponent)

Source from the content-addressed store, hash-verified

1679
1680 @classmethod
1681 def compile_from(cls, component: BaseComponent) -> BaseComponent:
1682 """Walk through the component tree and memoize all stateful components.
1683
1684 Args:
1685 component: The component to memoize.
1686
1687 Returns:
1688 The memoized component tree.
1689 """
1690 if isinstance(component, Component):
1691 if component._memoization_mode.recursive:
1692 # Recursively memoize stateful children (default).
1693 component.children = [
1694 cls.compile_from(child) for child in component.children
1695 ]
1696 # Memoize this component if it depends on state.
1697 stateful_component = cls.create(component)
1698 if stateful_component is not None:
1699 return stateful_component
1700 return component
1701
1702
1703class MemoizationLeaf(Component):

Calls 1

createMethod · 0.45

Tested by 3

test_stateful_componentFunction · 0.64
test_stateful_bannerFunction · 0.64