nustack
ReferenceNu STD

mem

nustd.mem: the shape fabric over plain nested Python dicts.

Module nustd.mem.

nustd.mem: the shape fabric over plain nested Python dicts.

A Shape declares slots, each slot is a ref, and every ref is a path of keys into one dict you hand in. No storage backend, no views, no reactivity: reads walk the dict, writes mutate it in place, and the dict stays yours to print, copy or dump.

A missing key on the way down reads EMPTY rather than raising, and a write creates whatever levels it needs, so a Shape can be laid over an empty dict and filled in as it goes.

Usage:

import nustd.mem as nm
from nu import Context
from nu.domains.shape import Shape

class User(Shape):
    name = nm.StrRef.slot()
    age = nm.IntRef.slot()

data = {}
ctx = Context().bind(dict, data, User)

Typed leaves (IntRef, StrRef, DatetimeRef, ...) each carry their value Form, so the ref itself is an operand. Containers (ListRef, DictRef, SetRef) hold a plain list, dict or set. ShapeRef, ShapesListRef and ShapesDictRef nest Shapes inside Shapes. ProgramRef holds Nu source. JQueueRef, in nustd.mem.refs.jqueue, holds a live janus queue and is imported by its own path.

Modules

ModuleWhat
nustd.mem.refs.jqueueJanus-backed queue ref for the nu-mem fabric.

refs.std

Module nustd.mem.refs.std.

Dict-substrate refs for standard-library value types.

Full entries

NameSortCallMeaning
BasisPointRefrefBasisPointRef(address, parent_ref=None, owner_shape=None)A BasisPoint slot in the dict substrate, stored as a raw int of bps.
ComplexRefrefComplexRef(address, parent_ref=None, owner_shape=None)A complex slot in the dict substrate, stored as str(complex).
DateRefrefDateRef(address, parent_ref=None, owner_shape=None)A date slot in the dict substrate, stored as an ISO string.
DatetimeRefrefDatetimeRef(address, parent_ref=None, owner_shape=None)A datetime slot in the dict substrate, stored as an ISO string.
DecimalRefrefDecimalRef(address, parent_ref=None, owner_shape=None)A Decimal slot in the dict substrate, stored as its exact string form.
FractionRefrefFractionRef(address, parent_ref=None, owner_shape=None)A Fraction slot in the dict substrate, stored as "numerator/denom".
PathRefrefPathRef(address, parent_ref=None, owner_shape=None)A filesystem path slot in the dict substrate, stored as a plain str.
PercentageRefrefPercentageRef(address, parent_ref=None, owner_shape=None)A Percentage slot in the dict substrate, stored as a raw float.
TimeRefrefTimeRef(address, parent_ref=None, owner_shape=None)A time-of-day slot in the dict substrate, stored as an ISO string.
TimedeltaRefrefTimedeltaRef(address, parent_ref=None, owner_shape=None)A timedelta slot in the dict substrate, stored as total seconds.
TimezoneRefrefTimezoneRef(address, parent_ref=None, owner_shape=None)A fixed-offset timezone slot, stored as its UTC±HH:MM string.
UUIDRefrefUUIDRef(address, parent_ref=None, owner_shape=None)A UUID slot in the dict substrate, stored as its hyphenated string.

refs.items

Module nustd.mem.refs.items.

Dict substrate item refs: typed value holders in nested dicts.

Full entries

NameSortCallMeaning
BoolRefrefBoolRef(address, parent_ref=None, owner_shape=None)A bool slot in the dict substrate, carrying the whole Bool surface.
BytesRefrefBytesRef(address, parent_ref=None, owner_shape=None)A bytes slot in the dict substrate, carrying the whole Bytes surface.
FloatRefrefFloatRef(address, parent_ref=None, owner_shape=None)A float slot in the dict substrate, carrying the whole Float surface.
IntRefrefIntRef(address, parent_ref=None, owner_shape=None)An int slot in the dict substrate, carrying the whole Int surface.
ItemRefrefItemRef(address, value_type, value_value_type, parent_ref=None, owner_shape=None)A single stored value in the dict substrate, with no value interface.
StrRefrefStrRef(address, parent_ref=None, owner_shape=None)A str slot in the dict substrate, carrying the whole Str surface.

refs.dict

Module nustd.mem.refs.dict.

Dict mapping reference: key-value container backed by nested dict.

Full entries

NameSortCallMeaning
DictRefrefDictRef(address, value_type, key_type, key_value_type, value_value_type, parent_ref=None, owner_shape=None)A mapping slot in the dict substrate, holding one plain dict of values.

refs.list

Module nustd.mem.refs.list.

Dict sequence reference: ordered container backed by nested list.

Full entries

NameSortCallMeaning
ListRefrefListRef(address, item_type, item_value_type, parent_ref=None, owner_shape=None)A sequence slot in the dict substrate, holding one plain list of values.

refs.prog

Module nustd.mem.refs.prog.

Dict-substrate ref for a stored Nu program.

Full entries

NameSortCallMeaning
ProgramRefrefProgramRef(address, parent_ref=None, owner_shape=None)A slot holding Nu program source, with the Program verbs on it.

refs.base

Module nustd.mem.refs.base.

Dict substrate refs: navigate nested Python dicts under the runtime.

Full entries

NameSortCallMeaning
RefBaserefRefBase(address, parent_ref=None, owner_shape=None)A slot addressed by a path of keys through nested Python dicts.

refs.set

Module nustd.mem.refs.set.

Dict set reference: unordered unique-element container.

Full entries

NameSortCallMeaning
SetRefrefSetRef(address, item_type, parent_ref=None, owner_shape=None)A set slot in the dict substrate, holding one plain set of values.

refs.shape

Module nustd.mem.refs.shape.

Dict shape reference: structured container backed by nested dict.

Full entries

NameSortCallMeaning
ShapeRefrefShapeRef(address, shape_type, parent_ref=None, owner_shape=None)A nested Shape slot in the dict substrate, stored as an inner dict.

refs.dictshape

Module nustd.mem.refs.dictshape.

Dict shapes dict reference: mapping of homogeneous shapes.

Full entries

NameSortCallMeaning
ShapesDictRefrefShapesDictRef(address, shape_type, key_type, key_value_type, parent_ref=None, owner_shape=None)A keyed collection of one Shape's records, stored as a dict of dicts.

refs.listshape

Module nustd.mem.refs.listshape.

Dict shapes list reference: sequence of homogeneous shapes.

Full entries

NameSortCallMeaning
ShapesListRefrefShapesListRef(address, shape_type, parent_ref=None, owner_shape=None)A list of one Shape's records, stored as a plain list of inner dicts.

On this page