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

Neil Hodgson nhodgson@bigpond.net.au
Tue, 30 Jul 2002 10:02:53 +1000


Scott Gilbert:

> I assume this means any call to getsafereadpointer()/getsafewritepointer()
> will increment the lock count.  So the UnlockObject() calls will be
> mandatory.

   The UnlockObject call will be needed if you do want to permit resizing
(again). It will not be needed for statically sized objects, including all
the types that are included in the PEP currently, or where you have an
object that will no longer need to be resizable. For example: you construct
a sound buffer, fill it with noise, then lock it so that a pointer to its
data can be given to the asynch sound playing function. If you don't need to
write to the sound buffer again, it doesn't need to be unlocked.

> Either that, or you'll have an explicit LockObject() call as
> well.  What behavior should happen when a resise is attempted while the
> lock count is positive?

   The most common response will be some form of failure, probably throwing
an exception. Other responses, such as buffering the resize, may be sensible
in particular circumstances.

   Neil