[Python-Dev] Extended buffer PEP

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Apr 9 03:00:05 CEST 2007


Travis Oliphant wrote:
> Carl Banks wrote:
> > I'd like to see it accept a flags argument over what kind of buffer 
> > it's allowed to return.  I'd rather not burden the user to check all 
> > the entries in bufferinfo to make sure it doesn't get something 
> > unexpected.
> Yes, I agree. We had something like that at one point.

Maybe this could be handled in an intermediate layer
between the user and implementor of the interface,
i.e. the user calls

   PyBuffer_GetBuffer(obj, &info, flags);

the object's tp_getbufferinfo just gets called as

   getbufferinfo(self, &info)

and PyBuffer_GetBuffer then checks that the result
conforms to the requested feature set. This would
relieve users of the interface from having to check
that themselves, while not requiring implementors
to be burdened with it either.

Possibly you might want to pass the flags on to
the object as well, in case it can reduce the
amount of work it has to do if not all the features
are being requested. But the object would be free
to ignore them if it wants.

--
Greg


More information about the Python-Dev mailing list