Optimisation

A track of P34 · Performance & Profiling.

Algorithm first, constant factors second: kill the quadratic before you vectorise, know when numpy or a cache pays off, and prove the win against a metered budget - the P34 capstone.

Once the profiler has told you where the time goes, this track is about spending your effort where it actually pays. The governing idea is an ordering: algorithm first, constant factors second. A better complexity class beats any micro-tuning on inputs large enough to matter — no amount of vectorising rescues a quadratic algorithm — so the first move is always to look for the repeated scan to replace with a lookup, or the recomputation to replace with a cache.

Only once the Big-O is right do constant factors earn attention. There, numpy is the big lever: it replaces a Python-level loop with one C-level operation over an array, a large win for numeric, array-shaped work (cross-link P4) and no help at all for branchy or object-heavy logic. Heavier tools — Cython, a Rust extension — come last, only when profiling proves one irreducible loop dominates and nothing simpler works.

What makes this track different is that it grades speed for real. The practice runs on the kernel, which meters CPU time, so a slow solution does not just earn a comment — it exceeds the budget and fails, while the optimised one passes. There is no fragile timing threshold to argue with: the complexity class is the gate. The track ends in the P34 capstone, a real performance ticket — profile a slow module, fix its biggest cost, and prove the win under a metered budget.

Fix the algorithmBig-O first — the order-of-magnitude winThen constant factorsnumpy / caching, where it paysMeasure against a budgetthe kernel meters CPUCapstoneprofile, optimise, prove it
Complexity before constant factors, and prove the win on evidence.