Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strings of Unknown Size #441

Open
YousefEZ opened this issue Aug 22, 2024 · 0 comments
Open

Strings of Unknown Size #441

YousefEZ opened this issue Aug 22, 2024 · 0 comments

Comments

@YousefEZ
Copy link

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?

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

No branches or pull requests

1 participant