[Python-Dev] pre-PEP: The Safe Buffer Interface
Guido van Rossum
guido@python.org
Mon, 29 Jul 2002 11:00:51 -0400
Thomas,
I like your PEP. Could you clean it up (changing 'large' into 'safe'
etc.) and send it to Barry? Some comments:
> Backward Compatibility
>
> There are no backward compatibility problems.
That's a simplification of the truth -- you're adding two new fields
to an existing struct. But the flag bit you add makes that old and
new versions of the struct can be distinguished.
> It may be a good idea to expose the following convenience functions:
>
> int PyObject_AsSafeReadBuffer(PyObject *obj,
> void **buffer,
> size_t *buffer_len);
>
> int PyObject_AsSafeWriteBuffer(PyObject *obj,
> void **buffer,
> size_t *buffer_len);
>
> These functions return 0 on success, set buffer to the memory
> location and buffer_len to the length of the memory block in
> bytes. On failure, they return -1 and set an exception.
Please make these a manadatory part of the proposal.
Please also try to summarize the discussion so far here. My personal
opinion: locking seems the wrong approach, given the danger of
deadlock; Scintilla can use the existing buffer protocol, assuming its
buffer doesn't move as long as you don't release the GIL and don't
make calls into Scintilla.
--Guido van Rossum (home page: http://www.python.org/~guido/)