We have written some documentation for Octave in order to guide people towards writing faster Octave code:
https://www.gnu.org/software/octave/doc/interpreter/Vectoriz...
But look at how much we have to explain, and look at all the hoops we have to jump through in Python and Octave in order to write faster code. Matlab used to have similar guides telling people don't write this, write that instead.
What Matlab eventually did was look at what people were writing and making that fast. Julia did the same and made it even faster.
This is a lesson from C and C++ compilers that seems to be taking a long time to trickle to other programming languages: as long as you're writing reasonable code, speeding up your code is your compiler's job, not yours. Your compiler usually knows better than you how to unroll loops, how to cache results, how to use multiple cores, how to elide unnecessary intermediate results, how to completely remove dead code. You should focus on writing easy to understand, maintainable, high-level code. That's why you're using a programming language and not machine code.