Skip to content

Conversation

davidhewitt
Copy link
Member

This is a proposal to make a first step towards resolving #5245

The idea is to add PyUntypedBuffer, which is a sibling to PyBuffer<T> which does not care about the actual element type it holds inside. I got the idea of the name from PyUntypedArray in rust-numpy.

I can imagine that this is potentially applicable in a number of cases where the user wants to attempt to get a buffer export from an object but doesn't necessarily know what element type the object will export. PyUntypedBuffer::get() can be used to get the export, .format() can then be inspected to deduce what concrete element T to cast the buffer to.

I think while we're here I moved a lot of the implementations of methods from PyBuffer<T> to PyUntypedBuffer, which may slightly reduce generic code bloat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant