Note that, depending if that makes sense to you (if all vectors involved are small), making everything static has a performance benefit:
julia> QO = SVector(1,2,3); dims=SVector(1); sel=SVector(1,2,3);
julia> @btime _ptrace_ket($QO, $dims, $sel)
1.644 ns (0 allocations: 0 bytes)
([1, 2, 3], [1])
vs (non-static):
julia> QO = [1,2,3]; dims=[1]; sel=[1,2,3];
julia> @btime _ptrace_ket($QO, $dims, $sel)
8.423 ns (1 allocation: 32 bytes)
([1, 2, 3], [1])