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

Neil Hodgson nhodgson@bigpond.net.au
Sat, 27 Jul 2002 10:51:39 +1000


Thomas Heller:

>     The size and pointer returned must be valid as long as the object
>     is alive (has a positive reference count).  So, only objects which
>     never reallocate or resize the memory block are allowed to
>     implement this interface.

   I'd prefer an interface that allows for reallocation but has an explicit
locked state during which the buffer must stay still. My motivation comes
from the data structures implemented in Scintilla (an editor component),
which could be exposed through this buffer interface to other code. The most
important type in Scintilla (as in many editors) is a split (or gapped)
buffer. Upon receiving a lock call, it could collapse the gap and return a
stable pointer to its contents and then revert to its normal behaviour on
receiving an unlock.

   Neil