Skip to main content

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 + OLAP layouts)

Build once (compiles _nxs.c with ../c/nxs.c for row, columnar, and PAX):

bash build_ext.sh

Conformance for columnar/PAX vectors (nyxis/conformance/run_py.py) requires this build; pure nxs.py covers row layout only.

Use the same API, significantly faster for columnar work:

import _nxs

reader = _nxs.Reader(buf)

# Columnar / PAX: zero-copy field buffers (numpy optional)
if reader.layout == "columnar":
    buf = reader.col_buffer("score")  # dict: values, bitmap, count (memoryviews)
    arr = reader.col_numpy_f64("score")  # numpy.ndarray, requires numpy
    total = reader.col_sum_f64("score")
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.

Metadata

Release files for nyxis 1.2.1

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

Source distribution (sdist)

Source distribution for nyxis 1.2.1
File Size Uploaded Provenance Actions
nyxis-1.2.1.tar.gz 17.2 kB With provenance Details for nyxis-1.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nyxis 1.2.1
File Interpreter ABI Platform Actions
nyxis-1.2.1-py3-none-any.whl Python 3 none any Details for nyxis-1.2.1-py3-none-any.whl

Total release size: 33.6 kB

Release files / nyxis-1.2.1.tar.gz

Download URL nyxis-1.2.1.tar.gz
Size 17.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c5109e4db899f084a2aaf70807524260c0d132059a19e582518cfe84886bca5f
BLAKE2b-256 checksum
How to use checksums
c757da0f2d1522318c557755d2e5c872c69f28d3c42a866328ff715d4d847130
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 24, 2026.

Transparency log

Release files / nyxis-1.2.1-py3-none-any.whl

Download URL nyxis-1.2.1-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
53a065abbdfb8de67cf3dcebc2ee2d3f0bddeebd91e38d023088ec084e494dff
BLAKE2b-256 checksum
How to use checksums
ff8c2e6c26f8a8323d2e31cc671dc7273529a936cef6d2351395a69a3dce5152
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 24, 2026.

Transparency log

Security for nyxis 1.2.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for nyxis-1.2.1.tar.gz

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 May 24, 2026.

Transparency log

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.

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