Skip to content

Epic 149: Arrow canonical interchange in Python - #109

Merged
rsasaki0109 merged 1 commit into
mainfrom
agent/epic149-arrow-interchange
Aug 7, 2026
Merged

Epic 149: Arrow canonical interchange in Python#109
rsasaki0109 merged 1 commit into
mainfrom
agent/epic149-arrow-interchange

Conversation

@rsasaki0109

Copy link
Copy Markdown
Owner

Summary

Promotes Arrow to the canonical cross-language zero-copy interchange in the Python bindings.

Deliverables

  • 149A PyPointCloud.__arrow_c_array__ — returns (arrow_schema, arrow_array) capsules from the audited C Data export, so pa.array(cloud), pandas, and DuckDB consume SpatialRust clouds zero-copy. Field buffers are CPU-backed and shared.
  • 149B PyPointCloudStream.__arrow_c_stream__ — returns a single arrow_array_stream capsule with direct get_schema/get_next/get_last_error/release callbacks driving the chunk iterator, consumable by pa.RecordBatchReader.from_stream. Bounded batch sizes are preserved.
  • Capsule destructors call the Arrow release callbacks exactly once (the consumer marks release null when it moves data); verified with PyArrow round trips plus gc.collect() showing no double free.
  • spatialrust-pipeline::StreamingPipelineIter::schema() additive accessor; pyarrow added to the Python CI job.

Verification

  • pytest -k arrow_c: pa.array(cloud) struct<float32 x,y,z> matches source; 1000-point stream yields 256/256/256/232 batches whose concatenated x matches a direct read.
  • Rust workspace tests pass; clippy -D warnings clean for spatialrust-py and spatialrust-pipeline; cargo fmt clean.
  • Local PyArrow 25 venv validated the full round trips.

PyPointCloud exposes __arrow_c_array__, returning (schema, array) Arrow
C Data capsules so PyArrow/pandas consume SpatialRust clouds zero-copy.
PyPointCloudStream exposes __arrow_c_stream__ for bounded record streaming
into pa.RecordBatchReader via direct ArrowArrayStream callbacks. Capsule
destructors call the Arrow release callbacks exactly once, verified by
PyArrow round trips and gc no-double-free in the wheel test gate. Add
StreamingPipelineIter::schema() accessor and pyarrow to the Python CI job.
@rsasaki0109
rsasaki0109 merged commit 18f26da into main Aug 7, 2026
105 checks passed
@rsasaki0109
rsasaki0109 deleted the agent/epic149-arrow-interchange branch August 7, 2026 10:37
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.

1 participant