-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Open
Labels
iterationInvolves iteration or the iteration protocolInvolves iteration or the iteration protocol
Description
I saw these recent changes: #22691, but maybe we can do better.
Even after these changes, the following example (from Discourse) still results in a SizeUnknown Flatten iterator:
using Base.Iterators: flatten
dr = [1:2, 4:7]
Base.iteratorsize(flatten(dr)) # SizeUnknown()It would be possible to simply define
Base.length(fl::Flatten) = mapreduce(length, +, 0, fl.it)
and to add UnitRange to this list, but maybe it would be nice to do this more generically? Base.iteratorsize could return HasLength() for fl::Flatten if all iterators in fl.it are HasLength or HasSize, and SizeUnknown otherwise. That would mean that Base.iteratorsize(::Flatten) could no longer be optimized into a constant however; is that a big issue?
Metadata
Metadata
Assignees
Labels
iterationInvolves iteration or the iteration protocolInvolves iteration or the iteration protocol