|
|
Subscribe / Log in / New account

Optimisation

Optimisation

Posted Aug 5, 2025 23:55 UTC (Tue) by tialaramex (subscriber, #21167)
Parent article: Python performance myths and fairy tales

> A compiler for C/C++/Rust could turn that kind of expression into three operations: load the value of x, multiply it by two, and then store the result.

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.


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds