◐ Shell
clean mode source ↗

Message 120297 - Python tracker

The culprit wrt copying Py_buffer structs seems mainly to be dup_buffer, which is called in memory_getbuf.  This seems unnecessary in the case where there's an underlying object and it has returned the view thru its own tp_as_buffer.  The underlying object at that point is solely responsible for releasing the buffer, so memory_getbuf shouldn't mess with it at all.  In the case where there is no underlying object (mainly thru PyMemoryView_FromBuffer), it probably should allocate any memory in the view in such a way that it can be freed in memory_releasebuf when the view->obj is NULL.