Yeah, I think in general this is hitting the tension you mentioned in the earlier PRs of early vs late validation.
The more I think about it the more I think we should move the validation to construction because:
- The only reason to create a
Variant in the first place is to access its data, so I think we would end up validating it almost immediately on read
Variants are constructed once but read many times so validating up front is probably faster
- We could offer an
unchecked variant for construction if performance overhead is hight that skips the validation
Originally posted by @alamb in #7666 (comment)
Yeah, I think in general this is hitting the tension you mentioned in the earlier PRs of early vs late validation.
The more I think about it the more I think we should move the validation to construction because:
Variantin the first place is to access its data, so I think we would end up validating it almost immediately on readVariantsare constructed once but read many times so validating up front is probably fasteruncheckedvariant for construction if performance overhead is hight that skips the validationOriginally posted by @alamb in #7666 (comment)