Streaming
Demonstrates Python generator streaming via PythonEmbed.stream(). Python generators are consumed lazily through a Java Iterator, avoiding memory explosion even for large datasets.
Key Points
py.stream("generator_expr")— returnsIterator<PythonValue>- Each
next()call resumes the generator and yields the next value - Only one value in memory at a time — safe for millions of items
- Works with built-in
range(), custom generators, and string generators