I was just toying around with this and found the following weird performance issue (Julia Version 0.7.0-DEV.4570):
function f(::Type{UInt16}, x::NTuple{2, UInt8})
x1 = 0x0001 * x[1]
x2 = 0x0100 * x[2]
x1 + x2
end
const NBytes{N} = NTuple{N, UInt8}
function f(::Type{UInt16}, x::NBytes{2})
x1 = 0x0001 * x[1]
x2 = 0x0100 * x[2]
x1 + x2
end
julia> @btime f(UInt16, (0x01, 0x02))
0.017 ns (0 allocations: 0 bytes)
0x0201
julia> x = NBytes((0x01, 0x02))
(0x01, 0x02)
julia> @btime f(UInt16, $x)
1.690 ns (0 allocations: 0 bytes)
0x0201