All Projects → akaihola → lusmu

akaihola / lusmu

Licence: BSD-3-Clause license
Lazy evaluation graph library. See the branch https://github.com/akaihola/lusmu/tree/fix-terminology for a version matching the PyCon Finland 2014 talk and related blog posts.

Programming Languages

python
139335 projects - #7 most used programming language
Authors: Antti Kaihola
Organization: Eniram Ltd
Copyright: 2013 Eniram Ltd. See the LICENSE file at the top-level directory of this distribution and at https://github.com/akaihola/lusmu/blob/master/LICENSE

Documentation | Source code | PyPI | Download | License

Lusmu – a dataflow/reactive programming library for Python

Lusmu is a Python library for reactive programming (a form of dataflow programming). Operations on data are done using a directed graph which consists of input nodes and calculation nodes.

Lusmu uses the invalidate/lazy-revalidate evaluation model: reading the value of a node triggers its calculation action and reads the values of its inputs. Thus, only required calculations are executed.

A minimal example

from lusmu.core import Input, Node, update_inputs

root = Input()
square = Node(action=lambda x: x ** 2,
              inputs=Node.inputs(root))

update_inputs([(root, 5)])
print square.value

The output:

25

See mouse.py and triangle.py for more comples examples.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].