One thing to keep in mind: the βmanual loopβ in numba very fast, essentially the same as the c-loop used by numpy operations.
In the first example, there are two operations: a temporary array ( c * b ) is allocated / calculated, then this temporary array is added to a . In the second example, both calculations occur in one cycle without an intermediate result.
Theoretically, numba can merge loops and optimize # 1 to do the same thing as # 2, but it doesn't seem to. If you just want to optimize your numpy operations, numexpr also be worth what was designed specifically for this, but probably won't be better than an explicit fuse loop.
In [17]: import numexpr as ne In [18]: %timeit -r10 test2(x, o, c) 1000 loops, best of 10: 1.36 ms per loop In [19]: %timeit ne.evaluate('x + o * c', out=x) 1000 loops, best of 3: 1.43 ms per loop
source share