def PyMemoryView_FromBuffer(space, view): """Create a memoryview object wrapping the given buffer structure view. The memoryview object then owns the buffer represented by view, which means you shouldn't try to call PyBuffer_Release() yourself: it will be done on deallocation of the memoryview object.""" if not view.c_buf: raise oefmt( space.w_ValueError, "cannot make memory view from a buffer with a NULL data " "pointer") buf = CBuffer(space, view.c_buf, view.c_len, view.c_obj) return space.wrap(W_MemoryView(buf))
def PyMemoryView_FromMemory(space, mem, size, flags): """Expose a raw memory area as a view of contiguous bytes. flags can be PyBUF_READ or PyBUF_WRITE. view->format is set to "B" (unsigned bytes). The memoryview has complete buffer information. """ readonly = int(widen(flags) == PyBUF_WRITE) view = CPyBuffer(space, cts.cast('void*', mem), size, None, readonly=readonly) w_mview = W_MemoryView(view) return w_mview
def newmemoryview(self, view): return W_MemoryView(view)
def newbuffer(self, w_obj): return W_MemoryView(w_obj)
def newmemoryview(self, w_obj): return W_MemoryView(w_obj)
def getbuffer_w(self, space): return space.wrap(W_MemoryView(BytesIOBuffer(self)))