akaihola / lusmu

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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

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.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Python 100.0%