Skip to content

Strings of Unknown Size #441

Open
Open
@YousefEZ

Description

@YousefEZ

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions