4 ms·
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 http
by billdueber 1y ago
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 https://ruby-doc.org/core-2.7.0/Enumerator/Lazy.html
- zelphirkalt 1y agoUltimately 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.
- hbogert 1y agoNot much different from having a `sort` in shell pipeline I guess?
- dorfsmay 1y agoI 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. https://peps.python.org/pep-0289/ https://peps.python.org/pep-0289/