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

Fix type instability in getproperty(::Schema, ::Symbol) #340

Merged
merged 7 commits into from
Oct 20, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Avoid ntuple for fieldcount above 512
MilesCranmer committed Aug 6, 2023
commit 4d4c9621cdb38d856301a473218b5e3a5a8de974
12 changes: 11 additions & 1 deletion src/Tables.jl
Original file line number Diff line number Diff line change
@@ -500,7 +500,17 @@
return names === nothing ? getfield(sch, :storednames) : names
elseif field === :types
T = getfield(sch, :storedtypes)
return types === nothing ? (T !== nothing ? T : nothing) : ntuple(i -> fieldtype(types, i), Val(fieldcount(types)))
if types === nothing
return (T !== nothing ? T : nothing)
bkamins marked this conversation as resolved.
Show resolved Hide resolved
else
ncol = fieldcount(types)
if ncol <= 512
# Type stable, but slower to compile
return ntuple(i -> fieldtype(types, i), Val(ncol))
else
return Tuple(fieldtype(types, i) for i=1:ncol)

Check warning on line 511 in src/Tables.jl

Codecov / codecov/patch

src/Tables.jl#L511

Added line #L511 was not covered by tests
end
end
else
throw(ArgumentError("unsupported property for Tables.Schema"))
end