Day 314 — Numba, for the loops that cannot be vectorised
Wednesday, 16 June 2027 · Week 45 of 52 · Production · Study day · 60 min
Path-dependent logic is the one case where a loop is the right algorithm, and it is exactly where pure Python is slowest, which is a narrow but real gap worth closing.
What you should be able to do tonight
- Compile one path-dependent function with numba and report the speedup against the pure Python and the vectorised versions.
- Say what numba cannot compile and how you find out before deploying it.
Tasks 60 min
30 min Compile your loop in no-python mode and measure it against the pure Python version and against any vectorised approximation. Report all three times and confirm the outputs match. Path-dependent code often shows two orders of magnitude, which is the largest single gain available in this phase.
20 min Find the boundaries: numba silently falls back to object mode unless you forbid it, which produces code that is slower and looks compiled. Force strict mode, then deliberately write something it cannot compile and observe the error rather than the silent fallback.
10 min Rerun the benchmark harness and record the new baseline, so the phase’s cumulative improvement is a number rather than an impression.
Resources
- Numba documentation tool
- Cython documentation tool
Deliverable
A numba-compiled path-dependent function with three timings compared and outputs verified identical, plus an updated benchmark baseline.
Checkpoint
Your numba function is only twice as fast. What is the first thing to check?
Prepare for tomorrow
Ten minutes tonight so Day 315, Thursday, 17 June 2027 starts clean. This is what the evening email sends you.
Record the cumulative speedup of your pipeline across the week from the benchmark harness.
Check your timed mixed-set scores.
Nothing to install.