-
Notifications
You must be signed in to change notification settings - Fork 952
Description
- Feature request: PyMemoryView
- Feature request: PyByteArray::new_with_size(num_bytes)
- Question: Can we allocate some buffer in python-side?
Consider this example:
let vec = vec![0;length];
// write on vec
// ...
return PyBytes::new(&vec[..]).to_object(py);
PyBytes::new is very slow because it copies. A memoryview on Rust slice works. but it is hard to manage the lifetime. If we can allocate on the python side from the beginning, the copy is not necessary. Is this possible?
let buf = some_allocation(length);
let bytes = buf.as_mut_bytes();
// write directly on bytes
// ...
return bytes;
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels