Vectorization & Broadcasting

Vectorization in NumPy

Transcript

Why loops are slow in Python, how ufuncs and broadcasting replace them, and how to structure code for cache-friendly access. We contrast readable vectorized expressions with over-squeezed one-liners, and mention when a small Cython or numba path might still be needed. You practice rewriting a simple loop as a single vectorized expression.