Gaynor: Buffers on the edge: Python and Rust
Alex Gaynor examines theawkwardness that comes when trying to interface Python and Rust code.
The challenge is that if you want to pass some bytes to a Rustlibrary to parse them (or do any other processing for that matter),the library almost certainly expects a &[u8], andthere's no way to turn a &[ReadOnlyCell<u8>]into a &[u8] safely, without allocating andcopying. And of course, the whole point of the Python bufferprotocol is to avoid these sorts of inefficiencies.Therefore, the regrettable solution is that, right now, there is noway to have all three of: efficiency, interoperability, andsoundness.