Optimize numeric array conversion and serialize directly into Python bytes
Some checks failed
Build / wheels (x86_64, ubuntu-latest) (push) Failing after 1s
Build / source (push) Failing after 1s
Build / lint (push) Failing after 1s
Build / wheels (aarch64, ubuntu-24.04-arm) (push) Has been cancelled
Build / wheels (arm64, macos-15) (push) Has been cancelled

This commit is contained in:
2026-09-21 22:48:21 -05:00
parent caee18aeef
commit 05cc505ef4
10 changed files with 328 additions and 13 deletions

View File

@@ -1,4 +1,23 @@
# pycapnp for openpilot
# pycapnp for IQPilot
IQ.Lvbs maintains this fork at https://git.konn3kt.com/IQ.Lvbs/pycapnp.
It extends comma's minimal branch at `caee18aeef0a9a54ad8f98292a325a1675a43bec`.
The upstream licenses and history are retained.
IQPilot additions:
- Native NumPy conversion for floating-point list readers and builders through
`__array__`, retaining inferred dtype, explicit casts and warnings, writable
independent output, and rejection of unsupported `copy=False` requests.
- `to_float64_bytes()` for an owned native-endian numeric snapshot without
constructing intermediate Python scalar objects. Non-numeric values are rejected.
- Direct serialization into the final Python bytes object, preserving segment
framing and byte identity while removing the intermediate flat-array copy.
NumPy is optional at runtime and loaded lazily only when its array protocol is used.
The validation suite additionally requires NumPy. Serialization reference hashes
were generated by the unmodified comma commit above and cover one and multiple
segments through megabyte payloads. The native helpers do not borrow message memory.
A serialization-only fork of [pycapnp](https://github.com/capnproto/pycapnp).
The `minimal` branch starts at upstream commit
@@ -39,7 +58,7 @@ CMake are required to build the vendored library.
```sh
uv venv --python 3.12
uv pip install cython setuptools wheel pytest build
uv pip install cython setuptools wheel pytest numpy build
.venv/bin/python setup.py build_ext --inplace
.venv/bin/python -m pytest
.venv/bin/python -m build