Study
NumPy · Vectorisation
Replacing Python loops with whole-array operations and ufuncs, with a timing comparison and the axis argument for reductions.
- Vectorised code runs the loop in compiled C instead of the Python interpreter.
- axis=0 reduces down the rows (one result per column); axis=1 reduces across each row.