uniffi-rs
uniffi-rs copied to clipboard
`bytes`/`string`s can be passed more efficiently
E.g. passing bytes from Python to Rust involves two copies, when it could be zero copies if the Rust code accepted &[u8]. The other way around currently involves two copies as well, which could be reduced to one (the creation of the Python bytes).
┆Issue is synchronized with this Jira Task ┆Issue Number: UNIFFI-281
Its not just about copies. Currently Rust bytes implementation uses for loop to copy individual bytes from RustBuffer into Vec<u8>. memcpy would be far more efficient.
Do you think using memcpy instead of for loop is a separate issue or not?
This issue title is broad enough I think it's fine to cover both cases. If it turns out a patch is submitted which only solves some inefficiencies but leaves others on the table, then it makes sense for a new more-specific issue to exist at that point.
Its not just about copies. Currently Rust
bytesimplementation usesforloop to copy individual bytes fromRustBufferintoVec<u8>.memcpywould be far more efficient.
Have you verified that it's not actually optimized into a memcpy already?
Good point, I didn't check that.