How to avoid allocations when reading arbitrary keys from a NamedTuple?

it’s just a type assertion, and as you’ve seen, the allocation happens before the assertion (during the getindex).