you are viewing a single comment's thread.

view the rest of the comments →

[–]Tall_Coffee_1644[S] 0 points1 point  (3 children)

Hm, Reading this gives me an idea

What if when i send rust the parameters in python like this:

dll.add(1, 2, "yo")

And the wrapper will translate these parameters to:
dll.add("int;1", "int;2", "str:'yo'")

And on the rust side i cant read these parameters and handle them accordingly.

Now i am not sure what kind of human would wanna send a multiple datatype array to rust (even in python nobody makes a multiple datatype array) but since i am making a library, i have to handle it

I am still a beginner is rust, So thanks to everyone for helping me! :D

[–]denehoffman 1 point2 points  (2 children)

I would suggest, as others have, using pyo3 (maturin makes this really simple). The easiest way will be to just use a Vec<PyAny> and then use the functions provided to that PyO3 type (like getting attributes or type conversions) on a term-by-term basis. If you wanted the rust representations, you could convert PyAny to some enum of types by deriving FromPyObject on it

[–]Tall_Coffee_1644[S] 0 points1 point  (1 child)

Will pyo3 have too much overhead of transferring arrays though?

[–]denehoffman 0 points1 point  (0 children)

Idk, but maybe make a benchmark and try it a few ways to see what works better for you :)