lusmu

A lazy/forced evaluation library


Keywords
eniram, reactive, lazy, evaluation
License
BSD-3-Clause
Install
pip install lusmu==0.2

Documentation

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.