Skip to content

Commit

Permalink
Fix JuliaData/DataFrames.jl#1734. The issue here, according to Keno, …
Browse files Browse the repository at this point in the history
…is the compiler can't quite optimize the getproperty w/ symbol => getfield w/ symbol on NamedTuples. Defining our own call to getfield w/ Int solves the issue by avoiding the symbol => index lookup. Long term, we should probably define our own getrowvalue function instead of overloading getproperty like we do, but we're doing it already, so we'll keep it in the short term. (#73)
  • Loading branch information
quinnj authored Feb 26, 2019
1 parent 4a159b3 commit b788a29
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/fallbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ end
elseif TableTraits.supports_get_columns_copy_using_missing(x)
return TableTraits.get_columns_copy_using_missing(x)
elseif istable(x)
return columns(IteratorWrapper(IteratorInterfaceExtensions.getiterator(x)))
iw = IteratorWrapper(IteratorInterfaceExtensions.getiterator(x))
return buildcolumns(schema(iw), iw)
end
throw(ArgumentError("no default `Tables.columns` implementation for type: $T"))
end
1 change: 1 addition & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ end

# generic fallback from getproperty w/ type information to basic symbol lookup
Base.getproperty(x, ::Type{T}, i::Int, nm::Symbol) where {T} = getproperty(x, nm)
Base.getproperty(x::NamedTuple{names, types}, ::Type{T}, i::Int, nm::Symbol) where {names, types, T} = Core.getfield(x, i)

"""
Tables.eachcolumn(f, sch, row, args...)
Expand Down

0 comments on commit b788a29

Please sign in to comment.