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

Greg Ewing greg@cosc.canterbury.ac.nz
Tue, 30 Jul 2002 12:21:42 +1200 (NZST)


> This restricts the set of objects that can be buffers to statically
> sized objects. I'd prefer that dynamically resizable objects be able
> to be buffers.

That's what bothers me about the proposal -- I suspect that this
restriction will turn out to be too restrictive to make it useful.

But maybe locking could be built into the safe-buffer protocol?

Resizable objects wanting to support the safe buffer protocol would be
required to maintain a lock count which is incremented on each
getsafebufferptr call. There would also have to be a
releasesafebufferptr call to decrement the lock count. As long as the
lock count is nonzero, attempting to resize the object would raise an
exception.

That way, resizable objects could be used as asynchronous I/O buffers
as long as you didn't try to resize them while actually doing I/O.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg@cosc.canterbury.ac.nz	   +--------------------------------------+