this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

project structure

+88 -5
+16
README.md
··· 1 1 # atmst 2 2 A Python library for wrangling atproto-flavoured Merkle Search Trees 3 + 4 + Current status: prototype 5 + 6 + ### Installation 7 + 8 + ``` 9 + git clone https://github.com/DavidBuchanan314/atmst 10 + cd atmst 11 + python3 -m pip install . 12 + `` 13 + 14 + dev install: 15 + 16 + ``` 17 + python3 -m pip install -e . 18 + ```
blockstore.py src/atmst/blockstore.py
+1 -1
carfile.py src/atmst/carfile.py
··· 2 2 from multiformats import varint, CID 3 3 import dag_cbor 4 4 5 - from blockstore import BlockStore 5 + from .blockstore import BlockStore 6 6 7 7 class ReadOnlyCARBlockStore(BlockStore): 8 8 """
+4 -2
mst.py src/atmst/mst.py
··· 9 9 from typing import Tuple, Self, Optional, Any, Dict, List, Set, Type, Iterable 10 10 from collections import namedtuple 11 11 12 - from util import indent, hash_to_cid 13 - from blockstore import BlockStore, MemoryBlockStore, OverlayBlockStore 12 + from .util import indent, hash_to_cid 13 + from .blockstore import BlockStore 14 14 15 15 # tuple helpers 16 16 def tuple_replace_at(original: tuple, i: int, value: Any) -> tuple: ··· 607 607 608 608 609 609 if __name__ == "__main__": 610 + from .blockstore import MemoryBlockStore, OverlayBlockStore 611 + 610 612 if 0: 611 613 import sys 612 614 sys.setrecursionlimit(999999999)
+35
mst_bench.py
··· 1 + import random 2 + from atmst import MemoryBlockStore, NodeStore, NodeWrangler 3 + from atmst.util import hash_to_cid 4 + import time 5 + 6 + dummy_cid = hash_to_cid(b"hello") 7 + 8 + def insert_random(n: int): 9 + bs = MemoryBlockStore() 10 + ns = NodeStore(bs) 11 + nw = NodeWrangler(ns) 12 + root = ns.get_node(None).cid 13 + nw.put_record(root, "0", dummy_cid) 14 + nw.put_record(root, "\xff", dummy_cid) 15 + for _ in range(n): 16 + root = nw.put_record(root, random.randbytes(8).hex(), dummy_cid) 17 + 18 + def insert_sequential(n: int): 19 + bs = MemoryBlockStore() 20 + ns = NodeStore(bs) 21 + nw = NodeWrangler(ns) 22 + root = ns.get_node(None).cid 23 + nw.put_record(root, "0", dummy_cid) 24 + nw.put_record(root, "\xff", dummy_cid) 25 + for i in range(n): 26 + root = nw.put_record(root, f"{i:08d}", dummy_cid) 27 + 28 + if __name__ == "__main__": 29 + start = time.time() 30 + insert_random(1000) 31 + print("insert random", time.time() - start) 32 + 33 + start = time.time() 34 + insert_sequential(1000) 35 + print("insert sequential", time.time() - start)
+3 -2
mst_test.py
··· 1 1 import random 2 - from mst import mst_diff, very_slow_mst_diff, MemoryBlockStore, NodeStore, NodeWrangler, hash_to_cid 2 + from atmst.mst import mst_diff, very_slow_mst_diff, NodeStore, NodeWrangler, hash_to_cid 3 + from atmst.blockstore import MemoryBlockStore 3 4 import time 4 5 5 6 PERF_BENCH = False ··· 42 43 43 44 if __name__ == "__main__": 44 45 duration = 0 45 - for _ in range(1 if PERF_BENCH else 20000): 46 + for _ in range(1 if PERF_BENCH else 200): 46 47 duration += random_test() 47 48 print("time spent diffing (ms):", duration*1000)
+26
pyproject.toml
··· 1 + [build-system] 2 + requires = ["setuptools>=61.0"] 3 + build-backend = "setuptools.build_meta" 4 + 5 + [project] 6 + name = "atmst" 7 + version = "0.0.1" 8 + authors = [ 9 + { name="David Buchanan", email="d@vidbuchanan.co.uk" }, 10 + ] 11 + description = "A Python library for wrangling atproto-flavoured Merkle Search Trees" 12 + readme = "README.md" 13 + requires-python = ">=3.8" 14 + classifiers = [ 15 + "Programming Language :: Python :: 3", 16 + "License :: OSI Approved :: MIT License", 17 + "Operating System :: OS Independent", 18 + ] 19 + dependencies = [ 20 + "dag_cbor", 21 + "multiformats", 22 + ] 23 + 24 + [project.urls] 25 + Homepage = "https://github.com/DavidBuchanan314/atmst" 26 + Issues = "https://github.com/DavidBuchanan314/atmst/issues"
+3
src/atmst/__init__.py
··· 1 + from .blockstore import BlockStore, MemoryBlockStore 2 + from .carfile import ReadOnlyCARBlockStore 3 + from .mst import NodeStore, NodeWalker, NodeWrangler
util.py src/atmst/util.py