Re:Python: Generators, Coroutines, Native Coroutines and Asy...
by luhn on Saturday December 05, 2015 @06:51PM
(#10683768)
How would that work? My understanding of async is that it's a way of interacting with IO. So how would the examples you give (additional, while loops) behave asynchronously, since they don't involve IO? (Except for maybe memory IO..?)
[ Parent
| on HN ]
Re:Python: Generators, Coroutines, Native Coroutines and Asy...
by chrisseaton on Saturday December 05, 2015 @07:54PM
(#10683917)
Addition still takes time though doesn't it? The idea is I could start an addition operation, and then be notified in some way when it's done.
I think the idea most similar to what the grandparent wants is instruction-level dataflow, where programs are DAGs, and instructions are only run when their inputs are ready, rather than when a program counter reaches them.
Physical dataflow machines were built that did this in hardware.
Re:Python: Generators, Coroutines, Native Coroutines and Asy...
by tomn on Saturday December 05, 2015 @09:44PM
(#10684157)
> programs are DAGs, and instructions are only run when their inputs are ready, rather than when a program counter reaches them.
At a low level, that's exactly what modern CPUs do.
Re:Python: Generators, Coroutines, Native Coroutines and Asy...
by chrisseaton on Sunday December 06, 2015 @07:23AM
(#10685086)
Right, but only on a single core and only over a small sliding window. Real data flow machines made it explicit rather than a fragile optimisation and scaled it up.
Re:Python: Generators, Coroutines, Native Coroutines and Asy...
by tomn on Sunday December 06, 2015 @11:25AM
(#10685599)
True, though with multiple functional units there is some parallelism. Just thought it was an interesting comparison.
Re:Python: Generators, Coroutines, Native Coroutines and Asy...
by luhn on Saturday December 05, 2015 @08:19PM
(#10683984)
A program as a DAG.... Whoa. That's an interesting concept to try to wrap your mind around.
Re:Python: Generators, Coroutines, Native Coroutines and Asy...
by harlowja on Saturday December 05, 2015 @10:00PM
(#10684196)
Just fyi, a library openstack (and myself and others) has created (in python) basically lets u program your workflow (really dataflow) as a DAG, and then the library will run it reliably (and in parallel and so-on). I'm more than willing to answer questions about how it does that if people are interested...
http://docs.openstack.org/developer/taskflow/
https://pypi.python.org/pypi/taskflow
And yes u can do things like built equation solvers to:
http://docs.openstack.org/developer/taskflow/examples.html#l...
And other neat things:
Re:Python: Generators, Coroutines, Native Coroutines and Asy...
by glittershark on Sunday December 06, 2015 @01:13PM
(#10685973)
That's exactly how Haskell's IO monad works (albeit a little simplified)