When to Use Maps or Records
Records are just tuples in disguise, so they have the same storage and performance characteristics as tuples. Maps use more storage than tuples and have slower lookup properties. On the other hand, maps are far more flexible than tuples.
Records should be used in the following cases:
-
When you can represent your data using a fixed number of predetermined atoms
-
When the number of elements in the record and the names of the elements will not change with time
-
When storage is an issue, typically when you have a large array of tuples and each tuple has the same structure
Maps are appropriate for the following cases:
-
Representing key-value data structures where the keys are not known in advance
-
Representing data with large ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access