Summary
During review of the downstream translation sync PR (QuantEcon/lecture-python-programming.zh-cn#17), several issues were identified in the Numba lecture content introduced by PR #512. These are source content concerns, not translation bugs.
Issues
1. @jit vs @njit equivalence claim may mislead readers
The lecture note states that @jit and @njit are now equivalent since nopython mode is the default. However, in some environments @jit can still fallback to object mode without raising an error. This could lead to readers getting inconsistent results, especially when they expect compilation failures to surface as errors.
Suggestion: Consider using @njit explicitly in all examples, or add a caveat about environment-specific behavior.
2. @jit(parallel=True) should be @njit(parallel=True)
The parallelization example uses @jit(parallel=True) with prange. Numba's parallel optimization requires the nopython compilation path; if @jit falls back to object mode, parallel=True may silently not take effect. Using @njit(parallel=True) (or @jit(nopython=True, parallel=True)) would guarantee the example behaves as described.
3. cache=True limitation in Jupyter environments
The new "Caching Compiled Code" section explains that cache=True stores compiled code to disk for reuse. However, Numba's disk caching typically requires functions to be defined in locatable module files. In Jupyter / Jupyter Book interactive environments (which this lecture is built with), cache=True may not work or may raise errors. A brief note about this limitation would help readers avoid confusion.
Source
Summary
During review of the downstream translation sync PR (QuantEcon/lecture-python-programming.zh-cn#17), several issues were identified in the Numba lecture content introduced by PR #512. These are source content concerns, not translation bugs.
Issues
1.
@jitvs@njitequivalence claim may mislead readersThe lecture note states that
@jitand@njitare now equivalent since nopython mode is the default. However, in some environments@jitcan still fallback to object mode without raising an error. This could lead to readers getting inconsistent results, especially when they expect compilation failures to surface as errors.Suggestion: Consider using
@njitexplicitly in all examples, or add a caveat about environment-specific behavior.2.
@jit(parallel=True)should be@njit(parallel=True)The parallelization example uses
@jit(parallel=True)withprange. Numba's parallel optimization requires the nopython compilation path; if@jitfalls back to object mode,parallel=Truemay silently not take effect. Using@njit(parallel=True)(or@jit(nopython=True, parallel=True)) would guarantee the example behaves as described.3.
cache=Truelimitation in Jupyter environmentsThe new "Caching Compiled Code" section explains that
cache=Truestores compiled code to disk for reuse. However, Numba's disk caching typically requires functions to be defined in locatable module files. In Jupyter / Jupyter Book interactive environments (which this lecture is built with),cache=Truemay not work or may raise errors. A brief note about this limitation would help readers avoid confusion.Source