Skip to content

Conversation

aplavin
Copy link
Member

@aplavin aplavin commented Jun 1, 2022

No description provided.

@piever piever requested a review from timholy June 8, 2022 18:19
@piever
Copy link
Collaborator

piever commented Jun 8, 2022

Seems reasonable to me. For tuples and named tuples the conversion would happen field by field regardless when calling setindex! and company on the component arrays. It may be best to add some comments explain the rationale in the code, as this seems like a somewhat delicate choice.

EDIT: thinking more about it, this has issues for nested structures. For example, the following errors here but works on master

julia> using StructArrays

julia> s = StructArray(x=StructArray(rand(ComplexF64, 1)))
1-element StructArray(StructArray(::Vector{Float64}, ::Vector{Float64})) with eltype NamedTuple{(:x,), Tuple{ComplexF64}}:
 (x = 0.1722611417806078 + 0.4879486345600308im,)

julia> push!(s, (x=1,))
ERROR: type Int64 has no field re

The reason is that push! does not recurrently call push! if some columns are StructArrays, but the whole thing is unrolled, for performance reasons. I suspect the correct implementation should take into account the "nesting structure" of the StructArray, though I'm not 100% sure what that would look like.

@timholy
Copy link
Member

timholy commented Jun 26, 2022

Personally, I would close this unless #228 gets a better example of a real problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants