How to know the size of a data type

Let me extend a bit the answer of @bernhard.

Because tuples are actually encoded as records, I will consider records instead of tuples in the following.

The protobuf @bernhard is referring to is the one used to encode values on the ledger API. Note that if you do not use the verbose mode, the fields record_id and label will not be set, meaning your record will have only a small constant overhead for w.r.t. your list.

To store the values in the ledger or to send transactions to other participants, we actually use a different though similar protobuf. Except for very old Daml-LF versions, records are encoding without type annotation nor field names similarly as for the ledger API non-verbose mode, so using records requires only a bit more memory than using lists.

In my opinion the different in space should be negligible enough to be simply ignored in most of the cases.

1 Like