3 ms·
People do it in C# a lot with Count and Length on Lists and Arrays and it ruins array bounds check elision. It is something that compilers do for you, in this
by gameswithgo 8y ago
People do it in C# a lot with Count and Length on Lists and Arrays and it ruins array bounds check elision.
It is something that compilers do for you, in this context, in most programming environments.
- uryga 8y agoUnfortunately, Python being hopelessly dynamic, `A.b` could involve executing arbitrary code and side effects depending on what `A` is. So hoisting `A_b = A.b` out of the loop may produce different results and thus can't be done automatically without some kind-of incredibly (impossibly?) smart static analysis :( (though perhaps a JIT could perform this optimization for the usual, non-surprising path)