Pipeline processing of data can be done either,
using generators only
Example generator in pipeline:
def grep(source, pattern=None): patternObject = re.compile(pattern) for line in source: if patternObject.search(line): yield line
using coroutines only
Example coroutine in pipeline:
@coroutine def grep(pattern): print "Looking for %s" % pattern while True: line = (yield) if pattern in line: print line,
Generators can be used to multiplex data from multiple sources, using threads.
Generators can be used to broadcast data to multiple consumers.
Generators are equally powerful in Concurrent programming
Why do we need couroutine using
send()(for ex: python)? When to use coroutine over generator?