3 ms·
Lazy enumeration can also save memory, because you aren’t storing entire collections during intermediate steps, and it works with infinite/unknown size collecti
by hakunin 2y ago
Lazy enumeration can also save memory, because you aren’t storing entire collections during intermediate steps, and it works with infinite/unknown size collections. Such as streaming data.
Some examples:
I wrote a utility gem a while ago that lets you lazily intersect, union, etc various potentially infinite streams of data. https://github.com/maxim/enum_utils/ https://github.com/maxim/enum_utils/
I also used lazy enumeration for traversing the wordmap in my no-RAM static storage gem. https://github.com/maxim/wordmap/ https://github.com/maxim/wordmap/
- hansvm 2y agoIn the worst case, that must have intermediate space requirements equal to the entire collections, right?
- pyinstallwoes 2y agoHow is it different than a window, rolling window?
- hakunin 2y agoIt's probably a version of that. But since data is assumed sorted, memory requirements almost never grow beyond one item per stream.