Skip to main content

PyO3 FFI bindings exposing the XQuad Rust runtime (xqvm + xqasm) to Python

Project description

xqffi — PyO3 FFI bindings for the XQuad Rust runtime

The Python extension that exposes the Rust xqvm interpreter and xqasm assembler. Ships as a manylinux wheel built by maturin.

xqffi is a pure FFI shim — it only re-exposes the Rust types and entry points. User-facing conveniences (Program / Session / RunResult, keyword calldata, trace inspection) live in the xquad umbrella package.

Install

pip install xqffi

Surface

xqffi.vm — low-level one-shot

What the conformance harness drives. Small wrapper over xqvm::Vm:

from xqffi.vm import Vm
from xqffi.asm import assemble_source

vm = Vm()
vm.set_calldata([40, 2])
vm.set_output_slots(1)
vm.run(assemble_source(src))
assert vm.outputs() == [42]

XqmxModel and XqmxSample are thin getter/setter wrappers around the Rust types for direct model/sample manipulation.

xqffi.asm — assembly

parse_xqasm(str) → wire dict; assemble_source(str) → raw bytes; disassemble(bytes) → human-readable listing; instruction_count(bytes) → instruction count.

Interactive / multi-run API

Use xquad.program for the REPL / notebook / script workflow:

from xquad.program import Program

program = Program.from_source(src)
session = program.session(output_slots=1)
session.set_calldata([40, 2])
result = session.run()
assert dict(result.outputs) == {0: 42}

Program.load(bytes) takes wire-format bytecode; Session.run() returns a RunResult with dict-keyed outputs (unset slots present as None), residual stack, and step count.

Also see

  • xqvm_py — pure-Python reference VM (conformance oracle).
  • xqcp — constraint programming DSL that compiles to .xqasm.
  • xqsa — solver adapters (dwave-neal).
  • xquad — umbrella meta-package with the interactive API.
  • docs/python-api-walkthrough.md — full tour.

License

AGPL-3.0-or-later.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xqffi-0.2.0.tar.gz (149.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xqffi-0.2.0-cp313-cp313-manylinux_2_34_x86_64.whl (443.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

File details

Details for the file xqffi-0.2.0.tar.gz.

File metadata

  • Download URL: xqffi-0.2.0.tar.gz
  • Upload date:
  • Size: 149.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.3

File hashes

Hashes for xqffi-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0de0ae239622131b7e3d3f25ce67557a12a9bae1695a4415df8507e9aa01e459
MD5 a1f14e8f00cdfe3c57e644f3bebee959
BLAKE2b-256 2deefe2a45643b8cfa5867abc3d5d34e93eecf2dd01405e5a2a5ba1a50381cfa

See more details on using hashes here.

File details

Details for the file xqffi-0.2.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for xqffi-0.2.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 868a98273088d7e4ab7b0b429c8ae86817b6ef3a0e8bdb41273d5671e75b1614
MD5 2f313407d274430878221d0cd0f0cd2c
BLAKE2b-256 1a8134c4f9d31348bbcbbc4f0f97305610ee1688c533bc21941739d1ec57f0b9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page