[Python-Dev] pre-PEP: The Safe Buffer Interface

Scott Gilbert xscottg@yahoo.com
Sun, 28 Jul 2002 16:57:12 -0700 (PDT)


--- Greg Ewing <greg@cosc.canterbury.ac.nz> wrote:
> Thomas Heller <thomas.heller@ion-tof.com>:
> 
> >    This PEP proposes an extension to the buffer interface called the
> >    'safe buffer interface'.
> 
> I don't understand the need for this. The C-level buffer
> interface is already safe as long as you use it properly --
> which means using it to fetch the pointer each time it's
> needed.
> 

This is not my PEP, but let me defend it anyway.

The need for this derives from wanting to do more than one thing at a time
in Python (multiple processors with multiple threas, asynchronous I/O, DMA
transers, ???).

One thread grabs the pointer from the "safe buffer interface" and then
releases the GIL while it works on that pointer.  Now another thread is
free to acquire the GIL and run concurrently with the first.  (The
asynchronous I/O case applies even on single processor machines...)

I believe you were the one to explain to me why an extension can't release
the GIL while it works with the PyBufferProcs acquired pointer.  This PEP
tries to allow the extension to do just that.






__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com