I assume Qutip uses sparse arrays. You can do the same in Julia (like you - I have not tried to optimize code - just added sparse):
julia> using SparseArrays
julia> function ψtest(K)
if K > 1 && K % 1 == 0
return kron(ψtest(K-1), sparse([-1. 0.;0. 1.]))
elseif K == 1
return 1/√(2) * sparse([0. 1.;1. 0.])
end
end
ψtest (generic function with 1 method)
julia> @time ψtest(16);
0.002063 seconds (182 allocations: 3.012 MiB)
julia> @time ψtest(25);
1.169190 seconds (290 allocations: 1.500 GiB, 17.61% gc time)
with dense matrix K=25 for sure will not fit in your RAM.