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
I'll investigate how Marimo routes
printand where that conflicts with Numba compilation. - Assistant
Implementing lazy
printoverride installation: keep builtinprintunlessmo.Threadis used. - Assistant
Moving
THREADSto break the circular import. - Assistant
The global install flag breaks tests with fresh kernels. Switching to per-globals idempotency instead.
- Assistant
Fixed:
printnow keeps builtin identity unlessmo.Threadis used.Problem
Marimo always installed
print_overridein kernel globals at startup. Numba requiresprintto be the actual builtin (identity check), so JIT compilation failed even in notebooks that never usedmo.Thread.Solution
- Stop installing
print_overrideat kernel startup —runtime.pyand test helpers now passprint_override_fn=None. - Lazy install on first
mo.Thread—mo.Thread.__init__callsinstall_print_override(ctx.globals), which patchesprintonly when threads are used. - Moved
THREADStoprint_override.py— avoids a circular import betweenthreads.pyandprint_override.py.
Behavior
Scenario printin globals - Stop installing
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.