A Python notebook in the terminal, inspired by marimo

gpython is a Python notebook designed for the terminal, taking inspiration from marimo. Its key feature is that cells are aware of which variables they define and use, and execution follows the resulting graph.

Performance benchmarks on a MacBook with Apple M3 Max (mean of 3 runs) show:

  • On screen: gpy in 0.3 s, against 1.1 s for JupyterLab's server and 0.4 s for marimo's
  • Run all 500 cells: gpy in 1.2 s, against 2.6 s for JupyterLab and 2.9 s for marimo
  • Memory: gpy uses the least at every notebook size

Note that JupyterLab and marimo are timed without their browser, so their real numbers are higher. The evaluation script ./scripts/eval.sh reruns the whole comparison and redraws the chart. Benchmark files and conditions are in docs/benchmarks/, and optimization details are in docs/optimizations.md.

The package on PyPI is called gpynb; the command it installs is gpython, with gpy as a short alias. The tool requires Python 3.13 or newer.

Installation

uv tool install gpynb        # installs the `gpython` command globally
gpython --update             # later, to get the newest release (--update dev: the newest code on GitHub)
uvx --from gpynb gpython     # or run it once without installing anything
pipx install gpynb           # if you use pipx instead of uv

To turn on tab completion in your shell (bash, zsh, fish or PowerShell), run once:

gpy --install-completions    # gpy --th + tab gives --theme; run it again after an upgrade

It writes one script under ~/.config and adds one line to your shell's start-up file (~/.zshrc, ~/.bashrc or the PowerShell profile; fish needs no line). Open a new terminal to use it. gpy --completions zsh prints the script if you want to place it yourself.

From a checkout, ./gpython runs the working copy (it creates the venv on first use); uv run gpython does the same. To use the working copy from any directory without root, uv tool install --editable . puts gpython and gpy in ~/.local/bin (uv tool update-shell adds it to PATH); gpy alone opens an untitled scratch notebook.

Usage

gpython                    # empty untitled notebook
gpython script.py          # a plain script is split into cells automatically
gpython a.py b.py          # several files: one tab each (gt / gT switch)
gpython notebooks/         # a directory: opens the file explorer there
gpy script.py              # gpy is a short alias for gpython; every form above works with it

More options are available on the Command line page of the full documentation. The documentation wiki covers: every command-line option such as --no-vim and --theme; run modes, the r ... run keys, concurrent cells, and the rules; every key and ex command; variables and the debugger; markdown cells; files, windows and tabs including explorer, outline, splits, and buffers; Python environments including venvs, uv, and installing packages; images (figures in the terminal); themes and status bar; configuration every setting such as concurrent cells and the run mode; file formats including scripts, # %%, marimo, and .ipynb; and development including source layout, tests, and releases.