Values¶
Values are instances of types. Value is the base class with factory methods
for creating and converting values.
When to use: Use values to hold typed data. Primitives are immutable; containers (Vector, Map, Set, XArray) are mutable.
Quick Start¶
from dsviper import Value, ValueString, ValueInt64, ValueVector, TypeVector, Type
# Direct construction for primitives
name = ValueString("Alice")
count = ValueInt64(42)
# Factory method with type (for containers)
t_vec = TypeVector(Type.INT64)
numbers = Value.create(t_vec, [1, 2, 3])
# Access underlying Python value
print(name.get()) # "Alice"
print(list(numbers)) # [1, 2, 3]
# Check type
print(name.type()) # string
Choosing the Right Pattern¶
Pattern |
When to Use |
Example |
|---|---|---|
|
Direct primitive construction |
|
|
Generic factory with type |
|
|
Deserialize from binary |
|
|
Type casting |
|
Base Class¶
A utility class to handle value instantiation and representation. |
Primitive Values¶
A class used to represent a value of type void. |
|
A class used to represent a value of type bool. |
|
A class used to represent a value of type uint8. |
|
A class used to represent a value of type uint16. |
|
A class used to represent a value of type uint32. |
|
A class used to represent a value of type uint64. |
|
A class used to represent a value of type int8. |
|
A class used to represent a value of type int16. |
|
A class used to represent a value of type int32. |
|
A class used to represent a value of type int64. |
|
A class used to represent a value of type float. |
|
A class used to represent a value of type double. |
|
A class used to represent a value of type string. |
|
A class used to represent a value of type blob. |
|
A class used to represent a value of type blob_id. |
|
A class used to represent a value of type commit_id. |
|
A class used to represent a value of type uuid. |
Container Values¶
A class used to represent a value of type vector<element_type>. |
|
Iterator for ValueVector elements. |
|
A class used to represent a value of type set<element_type>. |
|
Iterator for ValueSet elements. |
|
A class used to represent a value of type map<key_type, element_type>. |
|
Iterator for ValueMap keys. |
|
Iterator for ValueMap values. |
|
Iterator for ValueMap items (key-value pairs). |
|
A class used to represent a value of type xarray<element_type>. |
|
A class used to represent a value of type optional<element_type>. |
Algebraic Values¶
A class used to represent a value of type tuple<T0, ...>. |
|
Iterator for ValueTuple elements. |
|
ValueVec(type_vec [, initial_value]). |
|
A class used to represent a value of type mat<element_type, columns, rows>. |
|
ValueVariant(type_variant, initial_value). |
|
A class used to represent a value of any type. |
User-Defined Values¶
A class used to represent a value of type struct. |
|
A class used to represent a value of type struct. |
|
A class used to represent a value of type key<element_type>. |
Value Program¶
A ValueProgram is a sequence of opcodes that describe mutations to values.
Each opcode represents an atomic operation (set, update, union, subtract, etc.).
A class used to retreive opcodes. |
|
A class used to retreive the mutation opcodes for an instance of a concept for an attachment. |
|
A utility class to handle opcodes encoder and streamer. |
|
A class used to represent the type and the arguments of an opcode. |
|
A class used to represent the type and the arguments of a opcode. |
|
A class used to represent the type and the arguments of a opcode. |
|
A class used to represent the type and the arguments of a opcode. |
|
A class used to represent the type and the arguments of a opcode. |
|
A class used to represent the type and the arguments of an opcode. |
|
A class used to represent the type and the arguments of an opcode. |
|
A class used to represent the type and the arguments of an opcode. |
|
A class used to represent the type and the arguments of an opcode. |
|
A class used to represent the type and the arguments of an opcode. |