Re:Pipelining might be my favorite programming language feature
by billdueber on Monday April 21, 2025 @08:37PM
(#43757999)
If you add in a call to “.lazy“ it won’t create all the intermediate arrays. There since at least 2.7. https://ruby-doc.org/core-2.7.0/Enumerator/Lazy.html
[ Parent
| on HN ]
Re:Pipelining might be my favorite programming language feature
by zelphirkalt on Monday April 21, 2025 @09:59PM
(#43758419)
Ultimately it will depend on the functions being chained. If they can work with one part of the result, or a subset of parts, then they might not block, otherwise they will still need to get a complete result and the lazy cannot help.
Re:Pipelining might be my favorite programming language feature
by hbogert on Tuesday April 22, 2025 @02:24AM
(#43759548)
Not much different from having a `sort` in shell pipeline I guess?
Re:Pipelining might be my favorite programming language feature
by dorfsmay on Tuesday April 22, 2025 @09:10AM
(#43761673)
I do the same with Python, replacing multilevel comprehensions with intermediary steps of generator expressions, which are lazy and therefore do not impact performance and memory usage.