JIT accelerators caveats

Intermediate Accelerating numerics & developer hygiene
Created by Pavel · 29.04.2026 at 19:11 UTC

Numba (and similar tools) compile restricted Python/NumPy loops to machine code. They shine on tight numeric kernels with supported types and operations. They stumble on Python objects, arbitrary dicts, dynamic dispatch, and many library calls—falling back to object mode or refusing to compile.

Treat JIT as a specialised accelerator after you have a correct reference implementation and profiler evidence. Debugging compiled failures requires reading compiler diagnostics—another reason to keep a pure-Python slow path for tests.

Numba docs: [1].


Sources

University approvals: 0
Tasks
Question 1

Numba JIT is most reliable for:

Hint

Numeric hotspots, not Python object graphs.

Question 2

A Numba kernel fails in nopython mode because the loop indexes a Python list of arbitrary objects. The deeper issue is:

Hint

nopython needs typed, static structure.

Question 3

hot_kernel(xs) returns sum(x*x for x in xs) for floats (pure Python reference shape).

Hint

Simple accumulator pattern.

Starter code is prefilled; replace TODO blocks with your solution.
1 test case will be used for grading
Run checks runtime behavior only. Final correctness is evaluated when you submit.
Card Info
  • Topic: Accelerating numerics & developer hygiene
  • Difficulty: Intermediate
  • Completed: 0 users
Creator
Pavel
Pavel