Repository navigation
Running cells
gpython tracks which variables each cell defines and uses, and runs follow that graph.
Running a cell first runs the stale cells it depends on (never run, edited
since, or their inputs changed), then the cell. What happens to the cells
below it, the ones that use its variables, is the run mode (f3, saved):
-
lazy (the default): they are only marked stale. You run what you want,
when you want, without moving:
r 6runs cell c6,r cthis cell,r rthe cell you ran last,r Cthe cells down to this one,r athe cells after it,r Aall,r sthe stale ones (f4);r krestarts the kernel,r Rrestarts and runs all,r iinterrupts;r t 5times this cell over five runs and prints a bordered table under it (mean, median, std, variance, p50 / p90 / p99, min, max), like%%timeit(r talone runs it once;:timeit 5). The same keys work in the editor's normal mode, wherespace r …is a synonym. - reactive: they re-run automatically, like marimo.
Turn on with :set concurrent, off by default, saved: cells of a run that share no
state run at the same time, on threads in the one kernel. A cell may join others only if neither
writes anything the other reads or writes (Bernstein's conditions); gpython works this out from
the code, counting as a write every assignment, in-place change (xs.append, d[k] = v, a
function that changes a global), call it does not know, and effect such as writing a file,
seeding random or drawing with plt. Magics, top-level await, input() and breakpoint()
run alone. Each cell's output, errors and r i still work per cell. :groups (or
gpy --groups nb.py) shows the groups and what each cell waits for; :set concurrency=N caps
how many run at once (1 runs them one by one). After a group, the names its cells shared are
checked: if one changed anyway, its readers are marked stale and run one by one from then on
(:set noconcurrent_verify turns the check off). Network calls, sleeps and NumPy run in
parallel; pure-Python loops take turns (the GIL); cells that write files run one at a time.
While a group runs, NumPy's math libraries are held to their share of the cores with
threadpoolctl (a gpython dependency); a kernel in a project .venv or conda env needs it
installed there too, or parallel NumPy cells may oversubscribe the cores.
- A name may be defined in only one cell. Repeating the identical import
(
import seaborn as snsin two cells) is allowed; the first cell owns the name. - Names starting with
_are private to their cell. - In-place changes (
xs.append(1),d["k"] = v) at a cell's top level are tracked: readers below run after the mutator, and running the mutator first re-runs the cell that created the object so it starts fresh.
Use the notebook
- Getting started
- Command line
- Running cells
- Keys
- Commands
- Vim
- Markdown cells
- Variables and the debugger
- Images
Set up the workspace
Help and project