-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iterators that know their size after start has been called #22467
Comments
Related: #16708 |
@davidanthoff can't this be handled with implementation of a stateful iterator? In the new protocol |
I think the new iteration protocol handles this yes. |
Hm, I might be missing something, but I don't think this is addressed with the new protocol? How would a source indicate to a client that If a source returns https://github.com/queryverse/IteratorInterfaceExtensions.jl#iteratorsize2 has an implementation of what I'm suggesting. That works OK for now, as this is essentially just used to trigger a performance optimization, but I still think it would make sense to have this in base itself. |
The contract for |
FWIW though, I think the iteration protocol already expects that |
The proposal here is not that
Really? I certainly would not have guessed that at all from looking at the docs. Also, just very briefly looking through Julia base code, that does not seem to be how iterators are used, for example the code here would then be an incorrect consumption of an iterator, right? Wouldn't that also be a really odd interpretation with the current stateless design of iterators? If |
Another issue that has come up during the Query.jl design: I have a whole bunch of iterators that know their length after the
start
method has been called.Would it be possible to add another return value to
iteratorsize
that isHasLengthAfterStart()
, and if a type returns that it has to implementlength(source, state)
?The text was updated successfully, but these errors were encountered: