dsviper

The strongly typed Python runtime over the Viper C++ engine. Full Viper surface — types, values, persistence, serialization, services — exposed as Python classes ; Python natives accepted directly thanks to Metadata Everywhere.

Strong Typing

Unlike Python's permissiveness, dsviper raises exceptions immediately on type mismatch. No silent failures.

# Type checking at construction
Value.create(Type.BOOL, 4)
# ViperError: expected type 'bool', got 'int'

# Range validation
Value.create(Type.INT8, 256)
# ViperError: value is not in the range of 'int8'

Native Integration

Python natives (lists, dicts, tuples) are accepted as input. Metadata drives the conversion automatically.

# Python list → Viper Vector
Value.create(TypeVector(Type.INT64), [1, 2, 3])

# Let Viper infer the type
Value.deduce([1, 2, 3])  # → Vector<int64>

What's Included

The dsviper Python API surface — see the documentation for the full reference.

Types & Values

Complete type system: primitives, containers, structures, enums, variants.

Definitions

The runtime catalogue — Types + Attachments. Embedded in every database and every RPC payload ; merged on the fly. This is Metadata Everywhere.

Database

SQLite-backed persistence with transactions and schema migration.

Commit

Mutation DAG — CommitDatabase, CommitStore, the Commit Application Model — covered in its own dedicated section.

Service

Typed function pools promoted across the wire — covered in its own dedicated section.

Serialization

Binary and JSON codecs. Streaming support for large data.

Blobs

Binary large objects up to 2GB with content-addressed storage.

DSM tooling

Parse .dsm into DSM Definitions (symbolic) and Definitions (runtime). Encode and decode between DSM, JSON, binary, and HTML.

Quick Start

Installation
# Install from PyPI
pip install dsviper

# Verify installation
python3 -c "import dsviper; print(dsviper.version())"
# Output: (1, 2, 10)
Basic Usage (dynamic API)
from dsviper import *

# Universal constructor — Value.create(type, [initial_value])

Value.create(TypeFloat())
# 0.0

Value.create(Type.STRING, "hello")
# 'hello'

Value.create(TypeVector(Type.INT64), [1, 2, 3])
# [1, 2, 3]

# Type checking enforced — immediate error on mismatch
Value.create(Type.BOOL, 4)
# dsviper.ViperError: expected type 'bool', got 'int'

# Range validation
Value.create(Type.INT8, 256)
# dsviper.ViperError: value is not in the range of 'int8'
Versioned Persistence (with Kibo-generated typed proxies)
from dsviper import CommitDatabase, CommitMutableState, CommitStateBuilder
import model.attachments as ma

# Open a commit database
db = CommitDatabase.open("model.cdb")

# Create and modify typed data
key = ma.Tuto_UserKey.create()
login = ma.Tuto_Login()
login.nickname = "alice"
login.password = "secret"

# Commit with full history
state = CommitMutableState(CommitStateBuilder.initial_state(db))
state.attachment_mutating().set(ma.TUTO_A_USER_LOGIN, key, login)
db.commit_mutations("Add Alice", state)

# Read back
state.attachment_getting().get(ma.TUTO_A_USER_LOGIN, key)
# Optional({nickname='alice', password='secret'})

Start Building

Install dsviper and follow the tutorial to build your first application.