Optimisation
Optimisation
Posted Aug 5, 2025 23:55 UTC (Tue) by tialaramex (subscriber, #21167)Parent article: Python performance myths and fairy tales
Perhaps even more importantly, the compiler might well eventually emit some entirely different operations or none at all by the "As if" rule during optimisation. Idiom recognition is an extreme example of this, compilers for many decades have been able to spot idiomatic ways to express in a compiled language an idea that is not efficiently realised the way it's expressed. e.g. in C you'd write a loop to walk the bits in an integer and count how many are set, but the target CPU may have a POPCOUNT instruction which just does all of that. So the compiler doesn't emit a loop at all, just a single instruction.
I disagree with the dynamism / speed / simplicity trilemma. I think if you want speed you must give up dynamism AND simplicity. Of the two I mourn simplicity, but speed is hard to say "No" to.