ValueXArray¶
- class dsviper.ValueXArray¶
Bases:
ValueA value of type xarray<element_type>. Seamless with a Python seq[object].
An element is reached two ways: x[i] walks the elements the array holds, counting from the end for a negative i and out of range past len; x[position] takes the uuid a position carries, and a uuid the array does not hold is a missing key.
Or use Value.create(type_xarray [, initial_value]).
This constructor builds a new container over the same elements, so only a mutation inside an element shows through.
- END = 00000000-0000-0000-0000-000000000000¶
- append(value: _InputValues) ValueUUId¶
Append value to the end and return END.
END is the position past the last, not the one just created - position(len(self) - 1) answers that.
- at(position: ValueUUId, *, encoded: Literal[True] = True) _OutputValues | None¶
Return the element at the position or None.
encoded=False returns a Value rather than a native object.
- static cast(value: Value | _OutputValues) ValueXArray¶
Return value as a xarray<element_type>, or raise if it is not one.
- copy() ValueXArray¶
Return a deep copy.
- description(*, namespace: NameSpace | None = None) str¶
Return the value written out, then its type, as <value>:<type>.
namespace qualifies the type name; representation() gives the value alone.
- disable_position(position: ValueUUId) None¶
Disable the position, so it addresses nothing.
The position is kept rather than reused, so a position another replica still holds keeps resolving.
- extend(values: Sequence | ValueVector) ValueUUId¶
Extend by appending the values.
- hash() int¶
Return the hash value.
- index(position: ValueUUId) int | None¶
Return the index of the position, or None if the array does not hold it.
- insert(before_position: ValueUUId, value: _InputValues, new_position: ValueUUId | None = None) ValueUUId¶
Insert the value before_position and return the new position. Use new_position if specified, else a new position is created.
- insert_position(before_position: ValueUUId, new_position: ValueUUId) None¶
Insert before_position a new_position.
- items(*, encoded: Literal[True] = True) list[tuple[ValueUUId, _OutputValues]]¶
Return the list of (position, value) pairs. With encoded=True (default) a scalar value is a Python native; with encoded=False it is a typed Value.
- rebuild_from(source: ValueXArray, elements: Sequence[tuple[ValueUUId, _InputValues]]) None¶
Rebuild self ATOMICALLY from another XArray’s position layout (positions and deleted positions, copied opaquely from source) together with elements - a sequence of (position, value) pairs. The whole target state is installed in a single step, so self never passes through a partial state (no foreign-typed values, no positions without values). This is the trans-definitions (de)serialization of an XArray: source’s layout verbatim, elements provided already re-mapped to self’s domain.
- remove(position: ValueUUId) None¶
Remove the element at the position. The position is kept, addressing nothing: has_position() still answers True and at() None.
- representation() str¶
Return the value written out: the elements between square brackets, comma separated.
- size() int¶
Return the number of elements, which len() also answers.
- to_vector() ValueVector¶
Convert to a vector<element_type>.
- type_code() str¶
Return the code naming this kind of value, such as “int32”, “struct” or “vector”.
- type_xarray() TypeXArray¶
Return the type xarray<element_type>.