[Python-Dev] Buffer interface in abstract.c?

M.-A. Lemburg mal@lemburg.com
Tue, 03 Aug 1999 13:06:46 +0200

Jack Jansen wrote:
> Why not pass the index to the As*Buffer routines as well and make getsegcount
> available too? Then you could code things like
>   for(i=0; i<PyObject_GetBufferCount(obj); i++) {
>         if ( PyObject_AsCharBuffer(obj, &buf, &count, i) < 0 )
>                 return -1;
>         write(fp, buf, count);
>   }

Well, just like Greg said, this is not much different than using the
buffer interface directly. While the above would be a handy
PyObject_WriteAsBuffer() kind of helper, I don't think that this
is really used all that much. E.g. in mxODBC I use the APIs
for accessing the raw char data in a buffer: the pointer is passed
directly to the ODBC APIs without copying, which makes things
quite fast. IMHO, this is the greatest advantage of the buffer

Marc-Andre Lemburg
Y2000:                                                   150 days left
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/