Zero-copy reader for the Nyxis (NXS) binary format
Project description
NXS — Python
Zero-copy .nxb reader for Python 3.8+. Pure-Python implementation with an optional C extension for hot-path columnar scans.
Requirements
Python 3.8+. No pip install, no dependencies. The C extension requires a C compiler and Python headers.
Read a file
from nxs import NxsReader
buf = open("data.nxb", "rb").read() # or mmap.mmap() for true zero-copy
reader = NxsReader(buf)
print(reader.record_count) # instant — read from tail-index, no parse pass
obj = reader.record(42) # O(1) seek
print(obj.get_str("username"))
print(obj.get_f64("score"))
print(obj.get_bool("active"))
Columnar scan
scores = reader.scan_f64("score") # list of all values for one field
total = reader.sum_f64("score")
low = reader.min_f64("score")
high = reader.max_f64("score")
ages = reader.sum_i64("age")
C extension (hot path)
Build once:
bash build_ext.sh
Use the same API, significantly faster for columnar work:
import _nxs
reader = _nxs.Reader(buf)
print(reader.record(42).get_str("username")) # ~374 ns vs ~1.2 µs pure Python
total = reader.sum_f64("score") # 3.15 ms at 1M records
Write a file
from nxs_writer import NxsSchema, NxsWriter
schema = NxsSchema(["id", "username", "score", "active"])
w = NxsWriter(schema)
w.begin_object()
w.write_i64(0, 42)
w.write_str(1, "alice")
w.write_f64(2, 9.5)
w.write_bool(3, True)
w.end_object()
data: bytes = w.finish()
# Convenience: write from a list of dicts
data2 = NxsWriter.from_records(
["id", "username", "score"],
[{"id": 1, "username": "bob", "score": 8.2}]
)
Tests
python test_nxs.py # pure-Python
python test_c_ext.py # C extension (requires build_ext.sh first)
Benchmarks
python bench.py # pure-Python vs json.loads
python bench_c.py # C extension vs json.loads
Files
| File | Purpose |
|---|---|
nxs.py |
Pure-Python reader |
nxs_writer.py |
Pure-Python writer |
_nxs.c |
C extension source |
build_ext.sh |
Compiles _nxs.c → _nxs.cpython-*.so |
Query engine
from nxs import NxsReader, Eq, Gt, Lt, And, Or, Not, Query
data = open("data.nxb", "rb").read()
r = NxsReader(data)
# Count matching records
n = r.where(And(Eq("active", True), Gt("score", 80.0))).count()
# Iterate — yields dicts
for rec in r.where(Eq("active", True)):
print(rec["username"])
# First match or None
first = r.where(Gt("score", 99.0)).first()
# No predicate = all records
total = r.where().count()
Predicates
| Class | Matches |
|---|---|
Eq(key, value) |
equality — bool, str, int, float |
Gt(key, v) / Lt(key, v) |
numeric > / < |
Gte(key, v) / Lte(key, v) |
numeric >= / <= |
And(p1, p2) / Or(p1, p2) / Not(p) |
combinators |
Operator overloads: p1 & p2, p1 | p2, ~p.
For the format specification see SPEC.md. For cross-language examples see GETTING_STARTED.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nyxis-1.0.0.tar.gz.
File metadata
- Download URL: nyxis-1.0.0.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4e33fc60dd31f8b916a2cf93fb22ef52456f5aaf8416ea710cd1a0a05c776ef
|
|
| MD5 |
e865473da9e0f00c2d97c4ba0b1c8302
|
|
| BLAKE2b-256 |
aef3e01cc916030eef1c60a7dfdc6c7b25473f92dc8a8cc1f1014fb2909b98b7
|
Provenance
The following attestation bundles were made for nyxis-1.0.0.tar.gz:
Publisher:
publish-pypi.yml on nyxis-io/nyxis-drivers
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nyxis-1.0.0.tar.gz -
Subject digest:
a4e33fc60dd31f8b916a2cf93fb22ef52456f5aaf8416ea710cd1a0a05c776ef - Sigstore transparency entry: 1587359884
- Sigstore integration time:
-
Permalink:
nyxis-io/nyxis-drivers@229dc21f2fbf08fd9373d2f85990aa04a2feb425 -
Branch / Tag:
refs/tags/python/v1.0.0 - Owner: https://github.com/nyxis-io
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@229dc21f2fbf08fd9373d2f85990aa04a2feb425 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file nyxis-1.0.0-py3-none-any.whl.
File metadata
- Download URL: nyxis-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
809b0b46f27407c291a85dbf87c406cf814ead8e2e7e588d5af5e88f5b933f7f
|
|
| MD5 |
ae382f7c34cfc32824b3d6a412459f26
|
|
| BLAKE2b-256 |
1ae049beaa7971806cb2cb648a2739ba0500b5f7b0abfcbf8669ecd6c09e8236
|
Provenance
The following attestation bundles were made for nyxis-1.0.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on nyxis-io/nyxis-drivers
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nyxis-1.0.0-py3-none-any.whl -
Subject digest:
809b0b46f27407c291a85dbf87c406cf814ead8e2e7e588d5af5e88f5b933f7f - Sigstore transparency entry: 1587360565
- Sigstore integration time:
-
Permalink:
nyxis-io/nyxis-drivers@229dc21f2fbf08fd9373d2f85990aa04a2feb425 -
Branch / Tag:
refs/tags/python/v1.0.0 - Owner: https://github.com/nyxis-io
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@229dc21f2fbf08fd9373d2f85990aa04a2feb425 -
Trigger Event:
workflow_dispatch
-
Statement type: