Skip to main content

vcti-tree

Tree protocols and generic algorithms for the vcti ecosystem. Zero-dependency abstractions; pluggable backings.

Overview

vcti-tree defines what a tree is in the vcti ecosystem: three Protocols (ReadOnlyTree, MutableTree, LockableTree) parameterized in payload type T and handle type H, plus generic algorithms — DFS and BFS walks, ancestor/depth/path queries, locking guards — written against those Protocols. The Protocols specify semantics (what a tree must support); they do not prescribe storage. Any backing — numpy-array, pointer-based, dict-based — that satisfies the Protocols gets the algorithms for free. The package has no numpy or other heavy dependency; it is a pure-Python abstraction layer that downstream tree packages depend on.

Why this exists

Tree code in the Python ecosystem typically bundles storage, mutation, and traversal into a single class — every new tree implementation re-implements its own walker, its own navigation helpers, its own delete semantics. This package brings across a pattern that's well-established in C++: a small abstract interface defining what a tree is, multiple concrete implementations choosing their own storage, and generic algorithms written once against the interface and reused across every backing. The result is that adding a new tree implementation (numpy-backed, pointer-backed, persistent, …) doesn't mean rewriting walkers and guards — it means satisfying three small Protocols and inheriting the entire algorithm library. See docs/design.md for the full background and the design decisions.

Installation

pip install vcti-tree

In requirements.txt

vcti-tree>=2.1.0

In pyproject.toml dependencies

dependencies = [
    "vcti-tree>=2.1.0",
]

Quick Start

The protocols and algorithms are the API; you bring (or import) a backing. DictTree is the bundled dict-backed reference implementation — enough to build a tree and run the generic algorithms against it:

from vcti.tree.core import DictTree, dfs_preorder, ancestors, depth

tree = DictTree[str]("root")            # every tree has a root from the start
a = tree.create_child(tree.root_handle, "a")
b = tree.create_child(tree.root_handle, "b")
tree.create_child(a, "a1")

# Generic walks/queries work against any tree that satisfies the protocols.
print([tree.payload(h) for h in dfs_preorder(tree)])   # ['root', 'a', 'a1', 'b']
print([tree.payload(h) for h in ancestors(tree, a)])   # ['root']
print(depth(tree, a))                                  # 1

The protocols (ReadOnlyTree, MutableTree, LockableTree) and the rest of the algorithm set are importable from the same package root:

from vcti.tree.core import ReadOnlyTree, MutableTree, LockableTree
from vcti.tree.core import dfs_preorder, dfs_postorder, bfs
from vcti.tree.core import ancestors, depth, path, descendants

Dependencies

None. Standard library only.

Metadata

Release files for vcti-tree 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vcti-tree 2.1.0
File Size Uploaded
vcti_tree-2.1.0.tar.gz 28.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vcti-tree 2.1.0
File Interpreter ABI Platform
vcti_tree-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 44.9 kB

Release files / vcti_tree-2.1.0.tar.gz

Download URL vcti_tree-2.1.0.tar.gz
Size 28.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5c40c03ad81b99aeed09663d26fc35f30849162bd14f22d11fb7bdd44b5b68bd
BLAKE2b-256 checksum
How to use checksums
e79dcbb0d7333f8e4db34e2471800db9b91d6fb184869962c2352283b0ee4804
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / vcti_tree-2.1.0-py3-none-any.whl

Download URL vcti_tree-2.1.0-py3-none-any.whl
Size 16.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e23350e02bd485554285c42c848629f486363546e2517d70148aaf3a75de63ab
BLAKE2b-256 checksum
How to use checksums
336ac338b821dbd16427d08044e760a590501d42c25847029de01a08f24c1b95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page