Skip to main content

Virtuals

Virtual Python collections over any storage.

Dict, list, set, indexed dict, tree — they look and feel like native Python, but they don't physically exist as in-memory collections. They're virtual: lazy views that compose data structure logic over flat tuple-key storage. Any backend that implements the storage protocol gets every data structure for free.

Like SQLAlchemy for Python collections. No SQL, no specific backend. Define your structure, plug in a store.

PyPI: virtuals-py | Import: virtuals

What It Does

from virtuals import View, Container
from virtuals.storages.mem import InMemoryStorage
from virtuals.codecs import NoOpCodec

storage = InMemoryStorage(codec=NoOpCodec())
storage.open()

with storage.transaction() as tx:
    users = DictView.open_root(tx)
    users["alice"] = {"name": "Alice", "age": 30}
    users["bob"] = {"name": "Bob", "age": 25}

    # Navigate naturally
    for user_id, profile in users.items():
        print(f"{user_id}: {profile['name']}")

# Under the hood: flat KV pairs with tuple keys
# ("users", "alice", "name") -> "Alice"
# ("users", "alice", "age")  -> 30

Three Layers

Layer 1: Storage

Generic tuple-key KV store with lexicographic ordering.

storage.put(("users", "alice", "name"), "Alice")
value = storage.get(("users", "alice", "name"))

Layer 2: Container

Hierarchy and parent-child relationships over flat keys.

container = Container(storage, ("users", "alice"))
container.create()
children = container.children()  # ["name", "age"]

Layer 3: View

Data structure abstractions (dict, list, set) over containers.

users = DictView.open_root(tx)
users["alice"] = "data"

Installation

pip install virtuals-py
pip install virtuals-py[rocksdb]  # with RocksDB backend

Features

  • Virtual collections: Work with dicts, lists, sets over any KV backend
  • Tuple keys: Natural hierarchical addressing with lexicographic ordering
  • Backend agnostic: Works with any ordered KV store (RocksDB, LMDB, in-memory)
  • Observable: Watch for changes at any level of the hierarchy
  • Transactional: Full ACID support when the backend provides it
  • Lazy: Nothing materializes until accessed

Documentation

See docs/ for detailed documentation:

  • docs/layers/layer1_storage.md — Storage layer
  • docs/layers/layer2_container.md — Container layer
  • docs/layers/layer3_view.md — View layer
  • docs/general/architecture.md — Architecture overview
  • docs/general/philosophy.md — Design philosophy

License

Apache-2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

virtuals_py-0.1.1.tar.gz (151.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

virtuals_py-0.1.1-py3-none-any.whl (218.1 kB view details)

Uploaded Python 3

File details

Details for the file virtuals_py-0.1.1.tar.gz.

File metadata

  • Download URL: virtuals_py-0.1.1.tar.gz
  • Upload date:
  • Size: 151.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for virtuals_py-0.1.1.tar.gz
Algorithm Hash digest
SHA256 26ab3a10f2e548ad3c8c95174313bde85575b91ecb4ad6eebc73631a5ac944da
MD5 e2184d0b2210493a3e85c59183405f3d
BLAKE2b-256 cd1142aac16358422921c07f9a5cb3968fd6029a52dff96bbaaac74ec363e988

See more details on using hashes here.

Provenance

The following attestation bundles were made for virtuals_py-0.1.1.tar.gz:

Publisher: publish-py.yml on nustackdev/virtuals

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file virtuals_py-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: virtuals_py-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 218.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for virtuals_py-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0a512808e61da2b34ef99a96fb20ec70f0b75c473ae9a3212c948f41ecb2ac2a
MD5 07852686b2f708116078e76f78aa5af3
BLAKE2b-256 d4b1133804e43b3bc64b9601ae1e1fd8ae0e22cc3b34810d00d9d9c698afd1e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for virtuals_py-0.1.1-py3-none-any.whl:

Publisher: publish-py.yml on nustackdev/virtuals

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page