maxfischer2781 / chainlet

Python module for linking generators/iterators to processing chains
MIT License
1 stars 0 forks source link

Traversal paths and drivers #4

Closed maxfischer2781 closed 7 years ago

maxfischer2781 commented 7 years ago

The abstraction to chains and graphs does not expose concurrency: only a top-level fork of producers can be detected and requires inspection of the chain.

A possible solution is for chains/graphs to provide paths - a collection of each sequence the chain/graph encodes. For example, the graph a >> (b, c) creates the paths [ a >> b, a >> c]. A path is a linear chain, and a linear chain provides itself as its only path.

Paths could be the entities that drivers work on, allowing the appropriate parallelisation. This should also allows asyncio drivers.

maxfischer2781 commented 7 years ago

Main issue of the draft is that it does not reflect identity. With the paths [ a >> b, a >> c] for a >> (b, c), a is traversed twice when it should be only once.

A path iterator may be more appropriate, but requires checking for forks and chains and the like.

maxfischer2781 commented 7 years ago

Iteration over chains/trees can be broken down into the following primitives of input->output:

A flag on elements could expose this easily to iterators.

maxfischer2781 commented 7 years ago

Each ChainLink defaults to 1->1 connections, but can use the flags chain_join and chain_fork to mark itself as a n->? and ?->n connection. Standard objects use this already, and chains are sensitive to it. The joinlet and forklet decorators set the respective attributes.

maxfischer2781 commented 7 years ago

Changes are part of the current release.