Marimo's print routing breaks Numba compilation In notebooks that do not use mo.Thread,…
- User
Marimo's print routing breaks Numba compilation
In notebooks that do not use
mo.Thread,printmust retain builtin identity so Numba can compile functions that call it.mo.Threadmust continue routing output to the spawning cell, with output isolation between concurrent threads.Interface
No new interfaces are introduced.
- Assistant
Investigating how Marimo routes
printand where it conflicts with Numba compilation. - Assistant
Implementing lazy
printoverride installation on firstmo.Threaduse so notebooks without threads keep the builtinprint. - Assistant
Fixing a circular import by lazy-importing
install_print_overrideinThread.__init__. - Assistant
Adding tests for builtin print identity and lazy override installation:
- Assistant
The global
_print_override_installedflag doesn't reset when kernel sessions swap__main__. Switching to a per-module check: - Assistant
Fixed print routing so Numba and other tools that require the builtin
printwork in notebooks that don't usemo.Thread.Problem
The kernel always patched
printin__main__withprint_overrideat startup. That wrapper is not the builtin, which breaks Numba compilation for functions that callprint.Solution
Defer the override until
mo.Threadis first used:-
print_override.py— Addedinstall_print_override()that patches__main__only when needed. It checks the current__main__module (not a global flag), so it works correctly when kernel sessions swap modules. -
threads.py—mo.Thread.__init__callsinstall_print_override()(lazy import to avoid circular imports). -
runtime.pyand test helpers — Kernel startup no longer passes to .
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.