This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Sun May 03 00:04:00 -0700 2009 | |
| |
LICENCE | Sun May 03 01:13:08 -0700 2009 | |
| |
dataflow/ | Sun May 03 00:04:00 -0700 2009 | |
| |
readme.rst | Sun May 03 01:17:03 -0700 2009 | |
| |
setup.py | Sun Dec 13 02:54:59 -0800 2009 | |
| |
test/ | Sun May 03 00:04:00 -0700 2009 |
readme.rst
dataflow.py
dataflow.py is a port of larrytheliquid's ruby dataflow gem, mostly to see if a python version (without blocks) would be useable. Turns out it is, which is not what I'd initially expected. Having created it, I'm interested in seeing how it can be applied to concurrency problems as well as actor-like constructs.
dataflow functions:
- dataflow_vars: decorator for generating dataflow variables for a function
- spawn(callable, *args): start a thread using the given callable, plus any additional arguments
- var(name=None): create a new dataflow variable (with optional name)
- unify(var, value): set the value of a dataflow variable.
dataflow can provide arguments automatically:
@dataflow_vars
def sum_items(x, y, z):
# notice how the order automatically gets resolved
spawn(lambda: unify(y, x() + 2))
spawn(lambda: unify(z, y() + 3))
spawn(lambda: unify(x, 1))
return z() # => 6
or you can create them whenever you like:
f = var() spawn(lambda: unify(f, 'f')) f() # => 6
Accessing any attribute or item (dictionary key) of a dataflow variable automatically waits for it to be assigned, and passes that access onto its value:
f = var()
spawn(lambda: unify(f, {'key': 'val'})
f['key'] # => 'val'







