constant
constant
#
The unified constant node — an inline value of any JSON-backed scalar type.
One Constant node replaces the old per-type constants: it carries any
inline-JSON scalar value (Bool, Number, String, Time,
Location, ...) as that type's JSON encoding, and its return type is the
scalar's type, so any platform decodes the value through the return type. This
is also the seam a server interceptor uses to compute a value of any type at
generation time and drop it straight into the graph.
Constant
#
Bases: Procedure[T]
An inline constant value of a JSON-backed scalar type T.
Construct it from a scalar instance — Constant(value=Number(value=42)) —
or lift a raw value with [const][]. The value is stored as its JSON
encoding and the node's return type is the scalar's own type.
Attributes:
| Name | Type | Description |
|---|---|---|
value |
Setting[JSONScalar | bool | int | float | str | dict | list]
|
A scalar instance at construction; replaced by its JSON encoding. |
Source code in capturegraph-lib/capturegraph/procedures/nodes/process/constant.py
as_scalar(value)
#
The JSONScalar a raw bool / int / float / str stands for.
A scalar instance is returned unchanged. This is the value a Constant
carries, without building the node — so a literal can be compared for
equality (a map key naming a slot) before any node exists.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Source code in capturegraph-lib/capturegraph/procedures/nodes/process/constant.py
const(value)
#
Lift a scalar value or instance into a Constant node.
Accepts an existing Constant (returned as-is), any JSONScalar
instance, or a raw bool / int / float / str.