I mentioned this here earlier, but since then okvs improved things hugely 
and it's now only a factor of 2 slower than "normal" iterators, which 
likely makes it useful for anything except critical inner loops.

The basic idea is that you can turn any iterable into something that is 
"consumed" operation by operation (ie a stream).

https://github.com/andrewcooke/StatefulIterators.jl

Examples:

julia> using StatefulIterators

julia> s = StatefulIterator([1,2,3,4,5])
StatefulIterators.StatefulIterator{Array{Int64,1},Int64}([1,2,3,4,5],1)

julia> collect(take(s, 2))
2-element Array{Any,1}:
 1
 2

julia> eltype(s)
Int64

julia> read(s)
3

julia> readbytes(s)
16-element Array{UInt8,1}:
 0x04
 0x00
 0x00
 0x00
 0x00
 0x00
 0x00
 0x00
 0x05
 0x00
 0x00
 0x00
 0x00
 0x00
 0x00
 0x00


Reply via email to