Skip to content
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

don't force eager conversions when not necessary, fix #228 #229

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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