Strings of Unknown Size
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.4k
- Forks
- 141
- Avg merge
- 16m
- Merged PRs (30d)
- 3
Description
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?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining the PyArray1 type and the #[pyfunction] signature shown in the issue, then check the NumPy and PyO3 bindings for support for variable-width string arrays. Compare the <U1 and <U2 examples and document whether runtime string lengths are supported or what API change would be needed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, rust
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100