Explode
One item in, many items out
.explode(fn) calls fn(item) and emits each element of the returned iterable as a separate item. With no argument, .explode() iterates over the incoming item itself: it is the inverse of .batch(n).
Signature
Pipeline.explode(explode_function=None) -> Pipeline[OutPacket]python
from olympipe import Pipeline
def words(line: str) -> list[str]:
return line.split()
lines = ["olympipe chains steps", "in parallel"]
print(Pipeline(lines).explode(words).wait_for_result())
# Without a function, each item must already be iterable
print(Pipeline(range(7)).batch(3).explode().wait_for_result())Output
['olympipe', 'chains', 'steps', 'in', 'parallel']
[0, 1, 2, 3, 4, 5, 6]How it works
The step runs in its own process like a .task: the result of fn is iterated and each element is sent one by one to the next queue. An empty iterable produces no item.
