What a ufunc is
What it is
A universal function: a compiled operation applied element-wise over broadcast inputs. +, np.exp, np.maximum and np.isnan are all ufuncs, and they all share the same machinery.
Why it matters
It is the unit of vectorisation. If an expression is built from ufuncs it runs entirely in compiled code; if anything in it is a Python function called per element, it does not.
In the real world: Applying GST to 10 million order amounts in one line, running at the speed of compiled code rather than Python.
x = np.array([1.0, 4.0, 9.0])
np.sqrt(x) # array([1., 2., 3.])
np.maximum(x, 2.0) # element-wise max against a scalar
x > 2 # a comparison is a ufunc too
np.exp(x).dtype # float64 — exp always leaves the integersUsing Python's math module on an array. math.exp takes a scalar, so it either raises or (worse, inside a comprehension) works one element at a time at Python speed.