Tables.jl icon indicating copy to clipboard operation
Tables.jl copied to clipboard

RFC: allow column access by `AbstractString`

Open simsurace opened this issue 1 year ago • 0 comments

Tables.jl currently supports column access by Integers and Symbols. Many implementations use Symbols to keep track of column names, such as DataFrames.Index. However, generating too many unique Symbols can lead to memory leaks because Symbols are not garbage collected. This calls for implementations which use something else, such as Strings or InlineStrings.

Could we add indexing by AbstractStrings to the Tables.jl specification? There could be a fallback definition

getcolumn(t, nm::AbstractString) = getcolumn(t, Symbol(nm))

but it would be possible to overload this function for a custom table type in order to bypass the conversion to Symbols.

Providing a method for the second argument being of type Symbol would still be mandatory.

In this way, an application consuming the Tables.jl API could use Symbols and AbstractStrings for indexing according to what's most appropriate for the problem at hand, while still supporting all kinds of table types.

simsurace avatar Feb 22 '23 21:02 simsurace