[Python-Dev] Fw: Behavior of buffer()

Guido van Rossum guido@python.org
Fri, 12 Jul 2002 11:36:52 -0400


I'm a little surprised.  Raymond Hettinger checked in a change that
makes all slices of buffer objects return strings.  His comments on SF
bug 546434 say that only one person replied and that they agreed
returning strings was the better solution.  But that's not how I read
the only response to his query that I see in python-dev, from Scott
Gilbert:

> Since the array module already has a way to create a ByteArray (and a
> ShortArray, and...), buffer objects don't really need to duplicate that
> effort.  Except creating an array from your own "special memory" (mmap,
> DMA, third party API), and backwards compatibility in general.  :-)
> 
> 
> 
> BTW: I chuckled when I saw you post this the first time.  This topic seems
> to draw a lot of silence.
> 
> I know that I would suggest deprecating the PyBufferObject to just being a
> BufferInspector, and taking what little extra functionality was in there
> and stuffing it into arraymodule.c.  Another solution would be to factor
> PyBufferObject into PyBufferInspector and a "bytes" object.  A few months
> ago, I was tempted to submit a PEP saying as much, but I think that would
> have quietly fallen to the floor.  Nobody seems to like this topic too
> much...

I read this as a recommendation to forget about returning strings.  Am
I mistaken?

Also, I wish you'd submitted that PEP.  IMO the reason that nobody
likes this topic is that there is much confusion about why we have
buffer objects in the first place.  Any attempt at clarifying this
(e.g. proposing separate byte arrays and buffer inspectors) would be
welcome.

--Guido van Rossum (home page: http://www.python.org/~guido/)