2 ms·
AFAIK, that is true for whole programs. What about a tiny routine that is executed millions of times deep inside a loop? You can get better performance by hand
by kirubakaran 18y ago
AFAIK, that is true for whole programs. What about a tiny routine that is executed millions of times deep inside a loop? You can get better performance by hand coding it, especially since you can have machine generated version for comparison.
Also, do you compile your python programs?
- wheels 18y agoThere are a lot of tricks to modern architectures and things that modern compilers can figure out. There's more to making things fast than using the right instructions -- modern optimizers also try to keep the CPU pipelines full, unroll loops where appropriate, try to detect operations that don't do anything, etc. Note that I'm not so much comparing against Python as comparing to calling a C function from Python (which is easy). The cases where you tend to want to do things in assembly are usually where there are assumptions that you can make about the execution that the compiler can't know.