I started using IterativeSolvers.jl in some of my work and found the iterator-based code to be easy on the eyes and rather slick. It seems to me that any Julia implementation of an iterative algorithm ought to adopt this style.
However, my reading of the various forum posts here suggests there is quite a bit of subtlety involved in the performance of iterators especially as they compare to a loop-based style. My takeaway from the discussion here:
- It should be possible to make an iterator as fast as a loop, and
- you can make an iterator (slightly) faster if you really know what you’re doing.
Syntactic sugar aside, I’m wondering if there are any general guidelines in choosing an iterator vs a loop approach? Are there patterns that should be avoided or that preclude a fast iterator implementation? Perhaps I’m asking the wrong question.
Separate but related question: Is there a goal to implement iterators for every algorithm currently in IterativeSolvers.jl? I could not find anything in the issues page or documentation.