nustack
ReferenceNu STDmem

refs.listshape

Dict shapes list reference: sequence of homogeneous shapes.

Module nustd.mem.refs.listshape.

Dict shapes list reference: sequence of homogeneous shapes.

Index descent (ref[i]) is the blueprint's __getitem__: it returns a ShapeRef at the index with this ref as parent_ref. The element shape type is passed to the blueprint as item_shape_type.

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.

ShapesListRef

A list of one Shape's records, stored as a plain list of inner dicts.

ShapesListRef(address, shape_type, parent_ref=None, owner_shape=None)

Path nustd.mem.ShapesListRef. Kind Ref, sort ref, cardinality scalar.

Subscripting descends: ref[i] is a ShapeRef at that index holding the element Shape, so rows[0].symbol is a full path down to a leaf and nothing is read until the whole chain runs.

Notes

  • Elements are plain dicts, so a record is appended by appending a dict, not a Shape instance.
  • In-place calls read the container first and do nothing when the slot is absent, so set an empty list before the first append.
  • An index past the end reads EMPTY rather than raising, like any other broken path.

Example

class Order(nu.Shape):
    symbol = nustd.mem.StrRef.slot()
class Book(nu.Shape):
    rows = nustd.mem.ShapesListRef.slot(Order)
ctx = nu.Context().bind(dict, {"rows": [{"symbol": "AAPL"}]}, Book)
nu.run(Book.rows[0].symbol, ctx)[0]
'AAPL'

Inherited methods

From nu.forms.collections.abc.sequence.MutableSequenceForm:

CallBuildsMeaning
.append(value)AnyAppend value to the end of self.
.extend(other)AnyExtend self with the elements of other, in order.
.insert(index, value)AnyInsert value at index, shifting later elements right.
.pop(index=-1)ElementResultTRemove and return the element at index.
.del_at(index)AnyRemove the element at index.
.remove(value)AnyRemove the first occurrence of value.
.reverse()AnyReverse self in place.
.sort()AnySort self in place, ascending, using the elements' natural order.
.copy()CollectionResultTShallow copy of self: a new sequence with the same elements.
.clear()AnyRemove every element from self.

From nu.domains.shape.refs.shapes_sequence.ShapesSequenceRef:

CallBuildsMeaning
a[key]ItemResultTInt index navigates to the child ShapeRef; slice routes to the form-level slice op.

From nu.forms.collections.abc.sequence.SequenceForm:

CallBuildsMeaning
.first_elem()ElementResultTFirst element of self.
.last_elem()ElementResultTLast element of self.
.index(value)IntLowest index in self where value is found, searching from the left.
.count(value)IntCount of occurrences of value in self.
.reversed()CollectionResultTSelf walked back to front, as a stream.

From nu.forms.collections.abc.collection.CollectionForm:

CallBuildsMeaning
.extract()objectMaterialise the full subtree rooted at self.

From nu.forms.collections.abc.sized.SizedForm:

CallBuildsMeaning
.len()IntLength of self.

From nu.forms.collections.abc.iterable.IterableForm:

CallBuildsMeaning
iter(a)Iterator[ElementT]Open self into a lazy iterator stream (Python's iter).

From nu.forms.collections.abc.container.ContainerForm:

CallBuildsMeaning
.contains(item)BoolWhether item is a member of self.

From nu.forms.collections.abc.sliceable.SliceableForm:

CallBuildsMeaning
.slice(start, stop, step=None)ResultTSlice of self from start to stop, stepping by step.

From nu.domains.shape.forms.collection.MutableCollectionForm:

CallBuildsMeaning
.set(value)SetCmdBuild a SetCmd.
.erase()EraseBuild an Erase.
.init(value)IfDoSet value iff the collection is currently missing.

From nu.domains.shape.forms.collection.CollectionForm:

CallBuildsMeaning
.exists()ExistsBuild an Exists query.
.missing()MissingBuild a Missing query.

From nu.lang.forms.Form:

CallBuildsMeaning
.is_empty()BoolTrue if this Form yields the EMPTY sentinel.
.is_invalid()BoolTrue if this Form yields the INVALID sentinel.
.is_sentinel()BoolTrue if this Form yields either sentinel (EMPTY or INVALID).
.not_empty()BoolTrue if this Form does not yield EMPTY.
.not_invalid()BoolTrue if this Form does not yield INVALID.

On this page