How to lazily apply things?

In the walkthrus, Jeremy mentions that the transforms are applied lazily. I am interested in how to code this. Which notebook should I refer to for the same? I believe generators and maps are examples of doing things lazily. What other things are lazy?

Iterators in general are lazy. Because generators are a type of iterators, that means that they are lazily evaluated as well. Another example of lazy evaluation in Python 3 is the range type. It’s not an iterator (it is an iterable, though, meaning you can get an iterator from it by passing it to iter()), but it is lazy because it does not store all of the numbers it will iterate over in a loop. It instead just calculates them as needed.

1 Like

For a quick example, take a look at TfmdLists here.

Look for the __getitem__ function, this is called when we index into a list. It is only at this point that the transform is applied at the item.