Skip to content

Proposal 0016: bb_python#19

Open
jimsynz wants to merge 1 commit into
mainfrom
proposal/0016-bb-python
Open

Proposal 0016: bb_python#19
jimsynz wants to merge 1 commit into
mainfrom
proposal/0016-bb-python

Conversation

@jimsynz
Copy link
Copy Markdown
Contributor

@jimsynz jimsynz commented May 22, 2026

Summary

Adds proposal 0016 — bb_python, a safety-aware Python integration layered over pythonx (Livebook's in-process CPython embedding).

Key shape:

  • Single BB.Python.Broker GenServer serialises Python access — one GIL, one interpreter, predictable scheduling
  • BB.Python.Robot Spark extension with a python do … end block carrying a pyproject.toml; uv_init runs at compile time for releases, runtime for dev
  • Pre-dispatch and mid-flight safety gating, the latter via PyThreadState_SetAsyncExc raising KeyboardInterrupt to interrupt in-flight Python work
  • BB.Python.PubSubBridge + an injected bb Python module exposing bb.on(name, fn), bb.publish(path, payload), bb.safety_state() — scripts cannot arm/disarm
  • Marshalling for Vec3 / Quaternion / Transform (as NumPy arrays) / Localize.Unit / BB.Message, plus opaque Pythonx.Object handoff so tensors don't round-trip through Elixir
  • Optional BB.Python.Action.Call and BB.Reactor.Step.PythonCall wrappers for symmetry with bb_jido and bb_reactor

Explicit non-goals: realtime control loops in Python, multiple interpreters, in-Python safety control.

Closes #17.

Test plan

  • Review against pythonx v0.4.10 to confirm API references (uv_init/2, Pythonx.eval/3, Pythonx.Encoder, Pythonx.Object) match current shape
  • Confirm the mid-flight safety interrupt approach (PyThreadState_SetAsyncExc) is reachable through pythonx's public surface, or scope it as a v0.2 follow-up
  • Decide on the open questions (Nerves cross-compilation recipe, out-of-process broker option, bb.spawn, atom decoding policy)
  • Move to implemented/ once bb_python ships

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Research and create a proposal for integrating BB with Python

1 participant