chainlet.primitives.chain module¶
-
class
chainlet.primitives.chain.Chain(elements)¶ Bases:
chainlet.primitives.compound.CompoundLinkA group of chainlets that sequentially process each data chunk
Parameters: elements (iterable[ ChainLink]) – the chainlets making up this chainNote: If elementscontains aChain, this is flattened and any sub-elements are directly included in the newChain.Slicing a chain guarantees consistency of the sum of parts and the chain. Linking an ordered, complete sequence of subslices recreates an equivalent chain.
chain == chain[:i] >> chain[i:]
Also, splitting a chain allows to pass values along the parts for equal results. This is useful if you want to inspect a chain at a specific position.
chain_result = chain.send(value) temp_value = chain[:i].send(value) split_result = chain[i:].send(temp_value) chain_result == temp_value
Note: Some optimised chainlets may assimilate subsequent chainlets during linking. The rules for splitting chains still apply, though the actual chain elements may differ from the provided ones. -
chain_fork¶ bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
-
chain_join¶ bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
-
chainlet_send(value=None)¶ Send a value to this element for processing
-