API reference

This page documents pipescript’s importable Python API – the helper functions re-exported from the top-level pipescript namespace, plus the entry point for registering namespace-block macros. Most day-to-day pipescript is syntax rather than API; you will typically reach for these names only when writing your own macros or calling a helper directly.

Helper functions

These are re-exported from pipescript (via pipescript.api) and are also the implementations behind several built-in macros (see Macros and helpers).

pipescript.api.utils.collapse(results: tuple[T | None, ...]) T[source]
pipescript.api.utils.lshift(obj: tuple[Any, ...]) tuple[Any, ...][source]
pipescript.api.utils.null(*_, **__) None[source]
pipescript.api.utils.peek(obj: T, *args, **kwargs) T[source]
pipescript.api.utils.pop(obj: T) tuple[T, Any][source]
pipescript.api.utils.push(obj: T) T[source]
pipescript.api.utils.replace(newval: T) Callable[[...], T][source]
pipescript.api.utils.rshift(obj: tuple[Any, ...]) tuple[Any, ...][source]
pipescript.api.utils.unnest(obj: tuple[tuple[Any, ...], Any]) tuple[Any, ...][source]
pipescript.api.static_macros.context(func, obj)[source]
pipescript.api.static_macros.do(func: Callable[[T, Unpack[tuple[T]]], Any], obj: T, *extra: T) T | tuple[T, ...][source]
pipescript.api.static_macros.expect(func: Callable[[T, Unpack[tuple[T]]], bool], obj: T, *extra: T) T | tuple[T, ...][source]
pipescript.api.static_macros.fork(funcs: tuple[Callable[[T, Unpack[tuple[T]]], Any]], obj: T, *extra: T) tuple[Any, ...][source]
pipescript.api.static_macros.future(func: Callable[[T, Unpack[tuple[T]]], R], obj: T, *extra: T) Future[R][source]
pipescript.api.static_macros.memoize(func: C) C[source]
pipescript.api.static_macros.ntimes(obj: T, callpoint_id: int) T[source]
pipescript.api.static_macros.once(callpoint_id: int) Any[source]
pipescript.api.static_macros.otherwise(func: C) C[source]
pipescript.api.static_macros.parallel(funcs: tuple[Callable[[T, Unpack[tuple[T]]], Any]], obj: T, *extra: T) tuple[Any, ...][source]
pipescript.api.static_macros.read(key: str, obj: T) tuple[T, Any][source]
pipescript.api.static_macros.repeat(func: Callable[[T, Unpack[tuple[T]]], T], obj: T, *extra: T) T | tuple[T, ...][source]
pipescript.api.static_macros.unless(func: Callable[[T, Unpack[tuple[T]]], bool], obj: T, *extra: T) T | tuple[T, ...][source]
pipescript.api.static_macros.until(func: Callable[[T, Unpack[tuple[T]]], bool], obj: T, *extra: T) T | tuple[T, ...][source]
pipescript.api.static_macros.when(func: Callable[[T, Unpack[tuple[T]]], bool], obj: T, *extra: T) T | tuple[T, ...][source]
pipescript.api.static_macros.write(key: str, obj: T) T[source]

Registering namespace-block macros

pipescript.tracers.macro_tracer.register_namespace_macro(name: str, builder: Callable[[dict], Any], call_form: Callable[[...], Any] | None = None) None[source]

Register name{ a = ...; b = ... } as a namespace-block macro.

The brace block is run and its top-level assignments harvested into a dict, which is passed to builder; the macro evaluates to builder(namespace). call_form, if given, is exposed as the bare name name (a builtin in a pipescript session) so the ordinary call form name(a=..., b=...) works too; pass the function that builder delegates to. Registration must happen before the cell/code using the macro is processed.