Why use NamedTuple data type? #268
-
Hello All. I hope you are well. This is a design question of Tables.jl. To my understanding, Tables.jl uses the NamedTuple data structure as its core type to work on. According to the help section on NamedTuples, it states "NamedTuples are immutable; neither the names nor the values can be modified in place after construction." Because NamedTuple is immutable, I would think that this would cause some performance issues. (Such as, recreating a new NamedTuple anytime a change is performed.) What are the reasons why Tables.jl is built around NamedTuples instead of another, mutable, data structure? I'm slowly gaining proficiency in Julia, so if my question is excessively naive, I apologize. Thank you for your time. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Beta Was this translation helpful? Give feedback.
-
No worry about asking at all. A vector of NamedTuples or NamedTuple of vectors was chosen for two main reasons: 1) they're "builtin" to Julia, which means no additional dependency needed for Tables.jl, which aims to be a very foundational package and 2) they're meant to be simple table types to aid in testing or small, specific use-cases where they make sense. So definitely not meant as any kind of "full" table type or DataFrame, but also simple enough that they can be useful in certain workflows. Hope that helps! |
Beta Was this translation helpful? Give feedback.
No worry about asking at all. A vector of NamedTuples or NamedTuple of vectors was chosen for two main reasons: 1) they're "builtin" to Julia, which means no additional dependency needed for Tables.jl, which aims to be a very foundational package and 2) they're meant to be simple table types to aid in testing or small, specific use-cases where they make sense. So definitely not meant as any kind of "full" table type or DataFrame, but also simple enough that they can be useful in certain workflows.
Hope that helps!