http://opensource.imageworks.com/?p=pyp
The Pyed Piper Tutorial: http://www.youtube.com/watch?v=eWtVWF0JSJA
http://opensource.imageworks.com/?p=pyp
The Pyed Piper Tutorial: http://www.youtube.com/watch?v=eWtVWF0JSJA
Swapping pipe components at runtime with pipe_controller:
http://jugad2.blogspot.in/2012/10/swapping-pipe-components-a...
Using PipeController to run a pipe incrementally:
http://jugad2.blogspot.in/2012/09/using-pipecontroller-to-ru...
PipeController v.01 released - simulating UNIX-style pipes in Python:
http://jugad2.blogspot.in/2012/08/pipecontroller-v01-release...
Some ways of doing UNIX-style pipes in Python:
http://jugad2.blogspot.in/2011/09/some-ways-of-doing-unix-st...
Mostly out of frustration for PyP not being lazy (on large inputs it reads the entire file up-front, or at least used to).
But it was quite interesting to implement all the standard python idioms (like slicing) in a lazy way, and it's not that complicated a tool. I still use it a lot whenever I have a nontrivial pipeline to write.
py 'itertools.count(1)' | py 'itertools.islice(stdin, 0, 10, 2)'
However, the number of times that you need this are surprisingly rare. Most lazy operations don't require that each row be aware of the surrounding row context, and using the much simpler: py -x 'new_row_from_old_row(x)'
will get the job done in a lazy fashion. Usually, when you need rows to be context aware, as in: py -l 'sorted(l)'
or py -l 'set(l)'
it's just not possible to accomplish your task without reading in all of stdin.Some things can't be done without reading everything. But there are still a number of operations on "all of stdin" that can safely be done lazily. I'm particularly fond of "divide stdin into chunks of lines separated by <predicate>" [0]. Which does need context, but only enough to determine where the current chunk ends (typically a few lines).
`py` seems to be aimed at a single expression per invocation (nice and simple), while `piep` recreates pipelines internally (more complex but also means pipelines can produce arbitrary objects rather than single-line strings). So I'm not really sure how you'd do the above in `py` anyway.
[0] http://gfxmonk.net/dist/doc/piep/#piep.list.BaseList.divide