rust-numpy
rust-numpy copied to clipboard
Strings of Unknown Size
I'm attempting to make a function in rust-pyo3 that takes in an np.array[np.str_] but I don't want to fix the size of the string to a particular value. How do I go about writing the signature of that function, because the size of the string array will not always the same?
Example:
# python
import mylib
mylib.calculate(np.array(["a", "b"]) # <U1
mylib.calculate(np.array(["foo," "bar"]) # U<2
use pyo3::prelude::*;
use numpy::PyArray1;
#[pyfunction]
#[pyo3(signature=(arr))]
fn calculate(arr: PyArray1<???>) -> PyResult<()>
{
Ok(())
}
Is this functionality supported where we can determine the length of the strings at run-time rather than at compile-time?