-
Notifications
You must be signed in to change notification settings - Fork 3
constructing a FixedSizeArray
from a generator
#20
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
Comments
A related issue is that constructing |
nsajko
added a commit
that referenced
this issue
May 1, 2024
* introduce function `collect_as` for construction from an iterator Makes constructing `FixedSizeArray`s more convenient! Inspired by JuliaLang/julia#36288 This currently ignores `Base.IteratorElType`, xref https://discourse.julialang.org/t/i-dont-get-base-iteratoreltype/113604 The allocations in some code paths are probably excessive/could be optimized. But I guess this is good for a start. Fixes #20 * also test an iterator with `BigInt`-valued `size` and `length` * remove the premature optimization for `AbstractArray` * improve tests * add to the Readme * whitespace/formatting fix * delete two useless `nothing` lines One of these wasn't being recorded by code coverage (another Julia coverage bug, I guess). * simplify a bit
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Regular
Array
s can be conveniently constructed using comprehensions:The above is basically equivalent to constructing a generator and collecting it:
A proposal exists to have
Array
constructors behave equivalently tocollect
here: JuliaLang/julia#16029. We do need some nice way of constructingFixedSizeArray
s, so maybe we could have a constructor method that takes aBase.Generator
? Or at least aconvert
method.The text was updated successfully, but these errors were encountered: