quantecon_wasm exposes only the Matlab-like timers. Timer and timeit — the API the lectures have standardised on and the one the style guide mandates — are absent, so qe.Timer() raises AttributeError in a wasm build.
Current state
quantecon_wasm/util/__init__.py ends at:
from .timing import tic, tac, toc, loop_timer
and quantecon_wasm/util/timing.py defines exactly __Timer__, tic, tac, toc, loop_timer. There is no Timer class and no timeit. The package also has no quantecon_wasm/timings/ directory, which upstream Timer depends on for get_default_precision — so this is a two-part port, not a single-file copy.
Why the gap exists
|
version |
last commit |
QuantEcon.py-wasm |
v0.7.2-1 |
2025-01-24 |
QuantEcon.py |
v0.11.4 |
current |
Timer landed upstream in QuantEcon/QuantEcon.py#783 (2025-08-16) and timeit in QuantEcon/QuantEcon.py#794 (2025-08-27) — both after this package's last commit, so it never had the chance to pick them up. This is a concrete instance of the drift that #3 is about.
Why it matters now, not later
The collision is scheduled rather than hypothetical. lecture-wasm imports quantecon_wasm as qe in 4 lectures, and the series mirrors lecture-python-intro, where the style rule qe-code-004 ("use the quantecon.Timer context manager") targets timing magics that are still present in the mirrored copies:
| lecture-wasm file |
timing magics awaiting conversion |
lectures/monte_carlo.md |
8 (%%time) |
lectures/inequality.md |
2 (%%time) |
lectures/markov_chains_I.md |
2 (%time) |
The moment any of those is converted upstream and synced, the wasm build breaks on qe.Timer(). QuantEcon/compliance-lecture-style already carries the recommendation to convert them.
Separately, QuantEcon/QuantEcon.py#833 deprecates tic/tac/toc/loop_timer upstream (step 1 of QuantEcon/QuantEcon.py#786; removal targeted at v1.0). That PR does not affect this package — the fork has its own copy of timing.py with no warning — but when step 2 removes those functions upstream, this package becomes the only place in the org still carrying them, and the two APIs diverge in both directions at once: quantecon will have Timer/timeit and no tic/toc, quantecon_wasm the exact opposite.
Suggested scope
- Port
quantecon/timings/ (__init__.py, timings.py) to quantecon_wasm/timings/.
- Port
Timer and timeit from quantecon/util/timing.py into quantecon_wasm/util/timing.py, and export both from quantecon_wasm/util/__init__.py.
- Port the corresponding
TestTimer / timeit cases into quantecon_wasm/util/tests/test_timing.py.
- Keep
tic/tac/toc/loop_timer in place for now — nothing in wasm calls them, and removing them is a separate decision that should follow upstream's step 2 rather than lead it.
Worth checking during the port whether anything in Timer/timeit relies on behaviour Pyodide does not provide; time.perf_counter is available under Pyodide, but that is the thing to confirm rather than assume.
How this surfaced
An audit of whether QuantEcon/QuantEcon.py#833 would affect the lecture series. It does not — all nine repos in the lectures workspace manifest are clean of the deprecated timers — but the sweep turned up this package as the one place in the org whose timing API cannot follow the lectures. lecture-wasm uses neither API today, so nothing is broken right now.
🤖 Generated with Claude Code
quantecon_wasmexposes only the Matlab-like timers.Timerandtimeit— the API the lectures have standardised on and the one the style guide mandates — are absent, soqe.Timer()raisesAttributeErrorin a wasm build.Current state
quantecon_wasm/util/__init__.pyends at:and
quantecon_wasm/util/timing.pydefines exactly__Timer__,tic,tac,toc,loop_timer. There is noTimerclass and notimeit. The package also has noquantecon_wasm/timings/directory, which upstreamTimerdepends on forget_default_precision— so this is a two-part port, not a single-file copy.Why the gap exists
QuantEcon.py-wasmQuantEcon.pyTimerlanded upstream in QuantEcon/QuantEcon.py#783 (2025-08-16) andtimeitin QuantEcon/QuantEcon.py#794 (2025-08-27) — both after this package's last commit, so it never had the chance to pick them up. This is a concrete instance of the drift that #3 is about.Why it matters now, not later
The collision is scheduled rather than hypothetical.
lecture-wasmimportsquantecon_wasm as qein 4 lectures, and the series mirrorslecture-python-intro, where the style ruleqe-code-004("use thequantecon.Timercontext manager") targets timing magics that are still present in the mirrored copies:lectures/monte_carlo.md%%time)lectures/inequality.md%%time)lectures/markov_chains_I.md%time)The moment any of those is converted upstream and synced, the wasm build breaks on
qe.Timer().QuantEcon/compliance-lecture-stylealready carries the recommendation to convert them.Separately, QuantEcon/QuantEcon.py#833 deprecates
tic/tac/toc/loop_timerupstream (step 1 of QuantEcon/QuantEcon.py#786; removal targeted at v1.0). That PR does not affect this package — the fork has its own copy oftiming.pywith no warning — but when step 2 removes those functions upstream, this package becomes the only place in the org still carrying them, and the two APIs diverge in both directions at once:quanteconwill haveTimer/timeitand notic/toc,quantecon_wasmthe exact opposite.Suggested scope
quantecon/timings/(__init__.py,timings.py) toquantecon_wasm/timings/.Timerandtimeitfromquantecon/util/timing.pyintoquantecon_wasm/util/timing.py, and export both fromquantecon_wasm/util/__init__.py.TestTimer/timeitcases intoquantecon_wasm/util/tests/test_timing.py.tic/tac/toc/loop_timerin place for now — nothing in wasm calls them, and removing them is a separate decision that should follow upstream's step 2 rather than lead it.Worth checking during the port whether anything in
Timer/timeitrelies on behaviour Pyodide does not provide;time.perf_counteris available under Pyodide, but that is the thing to confirm rather than assume.How this surfaced
An audit of whether QuantEcon/QuantEcon.py#833 would affect the lecture series. It does not — all nine repos in the lectures workspace manifest are clean of the deprecated timers — but the sweep turned up this package as the one place in the org whose timing API cannot follow the lectures.
lecture-wasmuses neither API today, so nothing is broken right now.🤖 Generated with Claude Code