It's sometimes expensive to build them (because a Vec is allocated for
it), so it makes sense to reuse them.
I discovered this when I wanted to write matrix multiplication (for arbitrary matrix sizes) ‒ I had to do a strided iterators for the columns, but they were for single use. Because the stride returns a Vec, it needs to be allocated every time, which is expensive ‒ it's cheaper to clone the iterators themselves.
Or, would it make sense derive clone for some more iterator types as well?
It's sometimes expensive to build them (because a Vec is allocated for it), so it makes sense to reuse them.
I discovered this when I wanted to write matrix multiplication (for arbitrary matrix sizes) ‒ I had to do a strided iterators for the columns, but they were for single use. Because the
stride
returns aVec
, it needs to be allocated every time, which is expensive ‒ it's cheaper to clone the iterators themselves.Or, would it make sense derive clone for some more iterator types as well?