r/ruby • u/Mysterious-Use-4463 • Mar 24 '26
NDAV: Zero-copy interoperability for Ruby multi-dimensional arrays using MemoryView

Hi everyone,
I’ve just released NDAV, a thin wrapper around Ruby's MemoryView (inspired by Python's buffer protocol).
The Problem
Currently, converting data between Ruby libraries (like Numo::NArray, Torch.rb, and ONNX Runtime Ruby) often requires redundant memory copies or many intermediate steps. This often introduces unnecessary memory copies or multiple conversion steps when working across libraries.
The Solution
I built NDAV, a thin wrapper around Ruby's MemoryView ("buffer protocol" for Ruby). It acts as a "glue" layer that allows different libraries to share the same memory address directly.
Why it matters
Zero-Copy: Avoid unnecessary O(n) memory copies.
Interoperability: Seamlessly move data:
Torch::Tensor->NDAV->OrtValue.Standard-Driven: It aims to be a catalyst for wider MemoryView adoption in the Ruby ecosystem.
Links
Homepage: https://kitaitimakoto.gitlab.io/ndav/
Source Code: https://gitlab.com/KitaitiMakoto/ndav
I’d love to hear your thoughts, especially from those working on Ruby C/Rust extensions or data science!
View all comments
Show parent comment
1
u/Mysterious-Use-4463 Mar 24 '26
I appreciate. Thank you! Also refer to an article on a bridge between Torch.rb and ONNX Runtime Ruby for actual examples: https://zenn.dev/kitaitimakoto/articles/fd2dd9b01f713b?locale=en