-
-
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
Does collect
always return an Array or can it return AbstractArray
s?
#50051
Comments
Collect for |
I think we need to be a little careful generalizing this more. See Issue 47777. Briefly:
|
Most people probably collect for the
|
Reading the documentation again,
Perhaps "shape" should be replaced either by |
If I may propose behavior which should not be the case, illustrated on julia> v = collect(Float64, 1:2:5)
1.0:2.0:5.0
julia> typeof(v) <: AbstractArray
true One must be careful that collect actually produce concrete values, rather than another (implied) iterable entity which will be used to form a generator; or, even more surprising, an abstract representation from a concrete. In other words, let's not facilitate more abuse of |
Triage thinks collect means "return a new container where all the values are stored explicitly and contiguously" --- perhaps a DenseArray? I think it is currently always mutable as well. So I do think it can return something other than Docs should be updated. |
The documentation says
Array
but collect of
Iterators.product
breaks this promise:I think returning an AbstractArray is fine if the documentation is updated. Interestingly
collect(collect())
results in a normal Array. SoOffsetArrays
is following the documentation.The text was updated successfully, but these errors were encountered: