Summary
quantecon is deprecating the Matlab-like timers tic / tac / toc / loop_timer in favour of the Timer context manager and timeit. See QuantEcon/QuantEcon.py#833, which adds a DeprecationWarning to these functions (removal targeted for a later release). lectures/kesten_processes.md is the only lecture across the Python family still using them, so once the deprecation ships its build output will start emitting warnings.
Where it's used
lectures/kesten_processes.md imports and calls the deprecated API:
- Import:
from quantecon import tic, toc (around line 59) — can be dropped, since the file already does import quantecon as qe (line 54).
- Six
tic() … toc() pairs around lines 238/240, 246/248, 317/319, 323/325, 396/398, and 402/404.
Suggested change
Each block wraps a single call and just prints elapsed time, so it maps cleanly onto the Timer context manager (which prints on exit, exactly like toc()):
# before
tic()
data = generate_cross_section(firm).block_until_ready()
toc()
# after
with qe.Timer():
data = generate_cross_section(firm).block_until_ready()
All six pairs follow the identical shape, so this is a mechanical swap. Optionally, a label can be passed to distinguish the with-compile vs without-compile runs, e.g. qe.Timer("with JIT compile").
Notes
- No uses of
tac or loop_timer anywhere in the lecture, so nothing else needs porting.
- The upstream deprecation PR is still open, so there is no urgency — this just future-proofs the lecture and keeps its build output warning-free.
Summary
quanteconis deprecating the Matlab-like timerstic/tac/toc/loop_timerin favour of theTimercontext manager andtimeit. See QuantEcon/QuantEcon.py#833, which adds aDeprecationWarningto these functions (removal targeted for a later release).lectures/kesten_processes.mdis the only lecture across the Python family still using them, so once the deprecation ships its build output will start emitting warnings.Where it's used
lectures/kesten_processes.mdimports and calls the deprecated API:from quantecon import tic, toc(around line 59) — can be dropped, since the file already doesimport quantecon as qe(line 54).tic()…toc()pairs around lines 238/240, 246/248, 317/319, 323/325, 396/398, and 402/404.Suggested change
Each block wraps a single call and just prints elapsed time, so it maps cleanly onto the
Timercontext manager (which prints on exit, exactly liketoc()):All six pairs follow the identical shape, so this is a mechanical swap. Optionally, a label can be passed to distinguish the with-compile vs without-compile runs, e.g.
qe.Timer("with JIT compile").Notes
tacorloop_timeranywhere in the lecture, so nothing else needs porting.