Skip to content
TheChatArchiveThe Chat Archive
composer-2.5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

Marimo's print routing breaks Numba compilation In notebooks that do not use mo.Thread,…

  1. User

    Marimo's print routing breaks Numba compilation

    In notebooks that do not use mo.Thread, print must retain builtin identity so Numba can compile functions that call it. mo.Thread must continue routing output to the spawning cell, with output isolation between concurrent threads.

    Interface

    No new interfaces are introduced.

  2. Assistant

    I'll investigate how Marimo routes print and where that breaks Numba compilation.

  3. Assistant

    Implementing lazy print override installation: keep builtin print by default, and install the override only when mo.Thread runs.

  4. Assistant

    Breaking a circular import by lazy-importing install_print_override inside Thread.run().

  5. Assistant

    Fixed. Marimo was always installing print_override in the kernel's global namespace at startup, which replaced the builtin print and broke Numba compilation (Numba requires print is builtins.print).

    Changes:

    1. print_override.py — Added install_print_override() that patches print in __main__ only when needed.

    2. threads.py — mo.Thread.run() calls install_print_override() before the thread executes, so routing still works for thread output.

    3. runtime.py — Kernel startup no longer passes print_override to patch_main_module (print_override_fn=None).

    Behavior:

    • Without mo.Thread: print keeps builtin identity → Numba and similar tools work.
    • With mo.Thread: Override is installed on first thread run; print in threads routes to the spawning cell via THREADS + execution context (unchanged isolation logic).

    Added tests:

    • test_print_is_builtin_without_threads — verifies print is builtins.print in a normal kernel session
    • test_install_print_override_is_idempotent — verifies lazy installation

    All 16 related tests pass.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.