Skip to content

treex.compact

A decorator that enable the definition of Tree subnodes at runtime.

Source code in treeo/api.py
def compact(f):
    """
    A decorator that enable the definition of Tree subnodes at runtime.
    """

    @functools.wraps(f)
    def wrapper(tree, *args, **kwargs):
        with tree_m._COMPACT_CONTEXT.compact(f, tree):
            return f(tree, *args, **kwargs)

    wrapper._treeo_compact = True

    return wrapper