Nadata
Nadata is a declarative data schema and object-graph framework with its own
language. You describe your data model in .nastruct schema files, populate it
in .nadata data files, and get a typed, queryable, persistent object graph —
usable from the command line or as an embedded Python library.
# structs.nastruct — the model
class Human {
name: Str;
birthday: DateTime = DateTime();
@age(now: DateTime = DateTime.now()) -> DateTime {
return now - self.birthday;
}
}
# data.nadata — the data
tom = Human(name="Tom", birthday=DateTime(d=12, m=4, y=2003));
print("Tom is an adult:", tom.age(DateTime.now()).year >= 18);
Array[Human] adults = Human.where((h: Human) -> h.age(DateTime.now()).year >= 18);
Features
- Typed schema language — structs, inheritance, attributes with defaults,
constbind-once attributes, methods and computed properties, standalone functions;import "...";shares schema libraries across projects - String library and hash indexes — typed string members (
split,join,replace,contains, ...), and opt-in per-attribute hash indexes (index(Human, "email")+get_by(Human, "email", x)) with automatic insert / update / removal maintenance — O(1) equality lookups instead of full scans - Rich type system — sized integers/floats (
Int32,UFloat16, ...),Str,Bool,DateTime,Color,Array[T],Dict[K, V],Set[T],Queue[T]/PriorityQueue[T, P], sparse spatial grids (GridSquare2D[T],GridHex2D[T],GridCube3D[T]), shape-checkedTensor[T, d1, ...]with symbolic dims bound toconstattributes, entity references; indexing (arr[0],dict["k"]) and string concatenation - Error handling —
raise "message";andtry { ... } catch (err) { ... }in scripts and method bodies; runtime errors (indexing, I/O builtins) are catchable too, whilereturn/break/continuepass through - Declarative data files — forward and circular references, script
statements,
print, chained polymorphic queries - Runtime introspection —
elt.id,type(x),elt.list_attr()/list_methods(), schema-constrainedgetattr/setattr, and database-wideschema_classes()/schema_functions() - Persistence — whole-database dumps, dirty-only delta appends, and
removal tombstones to a single
.ndbfile - Bounded memory — disk-backed lazy rows (~50 bytes/row index), a
bounded LRU decode cache with clean-only eviction,
pin/unpin,flush/clear_cache, andremove_from_dbfrom scripts — stream millions of rows while the model stays hot - Autograd and training — tape-based reverse-mode differentiation on Float
tensors (arithmetic,
matmul, reductions, shape ops,gather, slices,relu), seeded data partitioning for train/valid/test splits, and built-inSGD— train models end-to-end in.nadatascripts - Sessions & identity — a project folder is a session:
#initseeds once per world,#autosyncs every open,#manualscripts take parameters (#manual(lr: Float = 0.05)), andnid = "name"gives instances stable, updatable identity (get_by_nid,nids,first/last) — schema files re-merge on every open, and schema evolution is reconciled against persisted rows (removed attributes are dropped; type changes are reported, never fatal). I/O builtins (read_json,write_csv,file_hash, ...) resolve against the project root, withget_setting/set_settingfreshness markers - Interactive console —
nadata console <path>REPL over any loaded database, with persistent state and expression echoing - Python API — load, query, mutate, execute raw source, persist
- Zero dependencies — pure Python 3.10+
Installation
git clone <repository-url>
cd Nadata
pip install -e .
pip install -e .[dev] # optional: pytest + mypy for development
Quick start
# Run a project (schema + data) and execute its scripts
nadata run examples/ex0_simple
# Print a summary of a project or a saved .ndb database
nadata info examples/ex0_simple
nadata info store.ndb
# Persist a project to a single database file
nadata dump examples/ex0_simple store.ndb
# Explore it interactively (works on folders and .ndb files)
nadata console examples/ex0_simple
nadata console store.ndb
Or from Python:
import nadata
app = nadata.Nadata.load("./examples/ex0_simple")
print(app.get_attribute("tom", "birthplace")) # Paris
print(app.count("Human")) # 3
app.dump("store.ndb") # persist
Documentation
| Document | Contents |
|---|---|
| docs/tutorial.md | Step-by-step tutorial: your first project |
| docs/syntax.md | Full language reference: rules and syntax |
| docs/architecture.md | How the engine works, stage by stage |
| docs/api.md | Python API and CLI reference |
| docs/persistence.md | The .ndb format, dumps and incremental saves |
| docs/benchmarks.md | Engine stage profiling, synthetic benchmarks, SQLite comparison |
| docs/development.md | Code style, testing, contributing |
Examples
The examples/ folder contains self-contained projects, from basics to
edge cases:
| Example | Demonstrates |
|---|---|
ex0_simple |
Family graph: inheritance, methods, forward refs, queries |
ex1_primitives |
Every sized integer/float type and boundary values |
ex2_inheritance |
Circular references, polymorphic queries |
ex3_collections |
Nested arrays, dictionaries, Color, DateTime math |
ex4_expressions |
if/else, boolean operators, local declarations |
ex5_edge_cases |
Parser edge cases: comments, spacing, empty constructs |
ex6_loops_collections |
Loops (for-in, C-style, while), fuel guards, collections |
ex7_queues_sets |
FIFO / priority queues, typed sets, membership probes |
ex8_grids_tensors |
Sparse spatial grids (square/hex/cube), shape-checked tensors |
ex9_constants |
const bind-once attributes, symbolic tensor dims |
ex10_cnn |
Conv1d/conv2d, pooling, and a basic convolutional neural network |
ex11_transformer |
A minimal transformer block: attention, LayerNorm, feed-forward, topk sampling |
ex12_optimizer_checkpoint |
Training a gelu network with Adam, checkpointing optimizer state to a sidecar file, and resuming from it |
Editor support
Syntax highlighting for .nastruct and .nadata files ships as a
VS Code / VSCodium extension in
editors/vscode-nadata. .vsix packages are
not stored in git — build one and install it:
cd editors/vscode-nadata
npx -y @vscode/vsce package --allow-missing-repository # -> nadata-support-<version>.vsix
code --install-extension nadata-support-<version>.vsix
Packaged releases attach the current .vsix to the matching git tag.
A sync test (tests/test_grammar.py) keeps the grammar aligned with the
language: it fails whenever a builtin type, keyword, or scope is missing.
Development
python -m pytest tests/ -q # run the test suite
python -m mypy nadata/ # type check (strict)
python -m scripts.inspect_parse examples/ex0_simple # inspect the parse IR
License
MIT — see LICENSE.
Metadata
Release files for nadata 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| nadata-0.1.0.tar.gz | 379.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nadata-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 675.1 kB
Release files / nadata-0.1.0.tar.gz
| Download URL | nadata-0.1.0.tar.gz |
|---|---|
| Size | 379.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
96b53d67abf3d5e8ca6dad81ea69963685ddcc2d765f42b8d7c3a8b1e9d35702
|
|
BLAKE2b-256 checksum How to use checksums |
42b60eda5396e1260a25b31dd5d7b64980e898283893aed1be5894620af66167
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / nadata-0.1.0-py3-none-any.whl
| Download URL | nadata-0.1.0-py3-none-any.whl |
|---|---|
| Size | 295.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
be9d91c993336cb0be734b0b606f9bf03e1f98e3c8f7919661a325e9030e1fdf
|
|
BLAKE2b-256 checksum How to use checksums |
d038c7ff11bf53b1463f02921edb11ce9acde3444c7161ac05a5b0fd6bc71f06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for nadata 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.