You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add PyMemoryView::from_owned_buffer for zero-copy memoryview creation
Adds a new method to create a Python memoryview that exposes a read-only
view of byte data owned by a frozen PyClass instance without copying.
This is useful for libraries like pyca/cryptography that need to expose
internal buffers efficiently.
The method uses PyBuffer_FillInfo + PyMemoryView_FromBuffer to create a
memoryview backed by the owner's data, with the owner kept alive via
the buffer's obj reference.
Safety is enforced at compile time:
- T: PyClass<Frozen = True> prevents mutation that could invalidate pointers
- for<'a> FnOnce(&'a T) -> &'a [u8] ensures the slice borrows from T or is 'static
Closes#5871https://claude.ai/code/session_01EEP1DaqJwHGCoNufi2JT9H
0 commit comments