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 breaks Numba compilation. - Assistant
Implementing lazy
printoverride installation: keep builtinprintby default, and install the override only whenmo.Threadruns. - Assistant
Breaking a circular import by lazy-importing
install_print_overrideinsideThread.run(). - Assistant
Fixed. Marimo was always installing
print_overridein the kernel's global namespace at startup, which replaced the builtinprintand broke Numba compilation (Numba requiresprint is builtins.print).Changes:
-
print_override.py— Addedinstall_print_override()that patchesprintin__main__only when needed. -
threads.py—mo.Thread.run()callsinstall_print_override()before the thread executes, so routing still works for thread output. -
runtime.py— Kernel startup no longer passesprint_overridetopatch_main_module(print_override_fn=None).
Behavior:
- Without
mo.Thread:printkeeps builtin identity → Numba and similar tools work. - With
mo.Thread: Override is installed on first thread run;printin threads routes to the spawning cell viaTHREADS+ execution context (unchanged isolation logic).
Added tests:
test_print_is_builtin_without_threads— verifiesprint is builtins.printin a normal kernel sessiontest_install_print_override_is_idempotent— verifies lazy installation
All 16 related tests pass.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- fable-5Compare side by side →
- fable-5Compare side by side →