Are you sure the Mojo code hasn't been optimized? It seems to be hand-tuned with simd operations and multi-threading.
> I don't know if there is more "compiler friendly" code with the same semantics for Mojo
The Mojo code here is from the official docs [1], so it's from the people best placed to know what the most "compiler friendly" code for Mojo would be, and what idioms they should use to get the best performance Mojo can provide.