Tracing np.add: From Python to SIMD
Tracing np.add, all the way down
NumPy's np.add is among the most executed lines of numerical Python, yet most users treat it as a black box. This deep dive traces a single call with float64 arrays from the Python entry point down to the SIMD kernel, revealing the machinery in between: argument parsing, __array_ufunc__ overrides, type promotion and dispatch, the trivial loop fast path versus NpyIter, and finally the inner loop itself. Along the way, we see how caching accelerates repeated calls, how the GIL is released for performance, and how strides affect execution.
The inner loop itself never checks anything, it just computes and sets CPU flags.