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

Greg Stein gstein@lyra.org
Tue, 03 Aug 1999 03:25:11 -0700


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);
>   }

Simply because multiple segments hasn't been seen. All objects
supporting the buffer interface have a single segment. IMO, it is best
to drop the argument to make typical usage easier. For handling multiple
segments, a caller can use the raw interface rather than the handy
functions.

Cheers,
-g

--
Greg Stein, http://www.lyra.org/