From 108d3b5ca895c81b18bdc66c9b2f8315541f8406 Mon Sep 17 00:00:00 2001 From: Martin Bernstorff Date: Sat, 9 Mar 2024 15:47:06 +0100 Subject: [PATCH] docs: documentation for eager iters --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 5b53b01..09af4e5 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,25 @@ result = (Iter([1, 2]) assert result == [4] ``` +### Lazy vs eager evaluation +Inspired by Polars, iterpy supports eager evaluation for easier debugging using `Arr`, and lazy evaluation for better performance using `Iter`. To access eager evaluation: + +```python +from iterpy import Arr + +result = Arr([1, 2, 3]).map(lambda x: x * 2).to_list() +assert result == [2, 4, 6] +``` + +To access lazy evaluation, just rename `Arr` to `Iter`: + +```python +from iterpy import Iter + +result = Iter([1, 2, 3]).map(lambda x: x * 2).to_list() +assert result == [2, 4, 6] +``` + ## Prior art iterpy stands on the shoulders of Scala, Rust etc.