[Python-Dev] buffer interface considered harmful

Fredrik Lundh fredrik@pythonware.com
Sun, 15 Aug 1999 12:32:59 +0200


> Fredrik Lundh wrote:
> >...
> > besides, what about buffers and threads?  if you
> > return a pointer from getreadbuf, wouldn't it be
> > good to know exactly when Python doesn't need
> > that pointer any more?  explicit initbuffer/exitbuffer
> > calls around each sequence of buffer operations
> > would make that a lot safer...
> 
> This is a pretty obvious one, I think: it lasts only as long as the
> object. PyString_AS_STRING is similar. Nothing new or funny here.

well, I think the buffer behaviour is both
new and pretty funny:

from array import array

a = array("f", [0]*8192)

b = buffer(a)

for i in range(1000):
    a.append(1234)

print b

in other words, the buffer interface should
be redesigned, or removed.

(though I'm sure AOL would find some inter-
resting use for this ;-)

</F>

    "Confusing?  Yes, but this is a lot better than
    allowing arbitrary pointers!"
    -- GvR on assignment operators, November 91