I just got a speed-up of factor ~17 on some BigInt code by using inplace operations, see https://discourse.julialang.org/t/a-plea-for-int-overflow-checking-as-the-default/3338/75?u=foobar_lv2.
Consider the line
n=3*n+1, appearing in an inner loop. If
n::BigInt, then this line is terrible, and one must
ccall into libgmp in order to do this operation in-place and avoid the allocation.
The best way of writing this would be
@. n=3*n+1 and have the macro figure out what to do. Then, one would also want to update the macro/lowering to also work for plain integers.
Is this doable? That is, (1) Make
@. a NOP for immutables, so that people can write generic code that avoids allocations both for
StaticArray and for
Array, and (2) Teach
@. to work on
Especially (1) might need breaking changes, if we also want
X .= Y; to be equivalent to
X = convert(typeof(X),Y); for immutable
X (or alternatively be equivalent to