Ecosystem Interoperability
RMath is designed to be a "drop-in accelerator." It implements standard memory protocols
like __array__ and __dlpack__ to ensure seamless, zero-copy compatibility with the Python scientific ecosystem.
Proven: Seamless NumPy Bridge
RMath implements the __array__ protocol, allowing standard NumPy
conversions. Because RMath uses Arc for safe, lock-free multithreading, data handed off to NumPy is securely cloned and isolated. This guarantees that your RMath data remains immutable and thread-safe.
import rmath.array as ra
import numpy as np
a = ra.ones(2, 2)
np_arr = np.asarray(a)
np_arr[0, 0] = 99.0
print(f"RMath a[0,0] : {a[0, 0]}")
print(f"NumPy [0,0] : {np_arr[0, 0]}")
RMath a[0,0] : 1.0
NumPy [0,0] : 99.0
Proven: PyTorch Zero-Copy
Using the DLPack protocol, RMath can pass data efficiently to PyTorch
with minimal overhead, making it easy to use RMath for data preprocessing before feeding tensors into neural networks.
import rmath.array as ra
import torch
ra_arr = ra.randn(10, 5)
th_tensor = torch.from_dlpack(ra_arr)
print(f"RMath Shape : {ra_arr.shape}")
print(f"PyTorch Shape : {th_tensor.shape}")
RMath Shape : [10, 5]
PyTorch Shape : torch.Size([10, 5])
Safety Philosophy: RMath prioritizes thread safety and lock-free parallelism over mutable shared state. Immutability in Rust is what allows RMath to run computations across 100% of your CPU cores without GIL bottlenecks.