Author skrah
Recipients jcon, kermode, mark.dickinson, ncoghlan, petri.lehtinen, pitrou, pv, rupole, skrah, teoliphant
Date 2011-07-04.10:28:57
SpamBayes Score 2.27083e-09
Marked as misclassified No
Message-id <>
In order to have a basis for discussion, I've set up a repo at

with an implementation of PyManagedBuffer. The whole test suite
passes, also with refleak counting and Valgrind.

Review is most welcome. If you think that this is roughly what
PyManagedBuffer is supposed to look like, I can add some tests
and documentation.

A couple of remarks:

  o I have used refcounting assumptions that appear to be valid
    for the Python codebase, but that need to be documented.

  o The docs state that if an underlying object supports writable
    views, the memoryview will be readable and writable. I use this
    in PyManagedBuffer_FromObject(). In fact there are tests that
    write to the original exporting object.

  o Releasing a view raises if more than one view is active.

  o get_shape0() is used in memory_length(). This does not seem
    correct if ndim > 1.

  o memory_getbuf() is still not a real getbufferproc, since it
    disregards almost all flags.

  o PyMemoryView_GetContiguous() needs to create a view with an
    underlying PyManagedBuffer. If the obj parameter is already
    a memoryview, the existing PyManagedBuffer has to be used,
    so I just do a check if the requested buffertype agrees with

    It would be possible to complicate the code further by having
    a PyMemoryView_FromObjectAndFlags().

  o In the non-contiguous case, PyMemoryView_GetContiguous() creates
    a new buffer, but the returned view does not use that buffer.
Date User Action Args
2011-07-04 10:28:58skrahsetrecipients: + skrah, teoliphant, mark.dickinson, ncoghlan, rupole, kermode, pitrou, pv, jcon, petri.lehtinen
2011-07-04 10:28:58skrahsetmessageid: <>
2011-07-04 10:28:58skrahlinkissue10181 messages
2011-07-04 10:28:57skrahcreate