[Python-Dev] buffer interface considered harmful
Jim Fulton
jim@digicool.com
Mon, 16 Aug 1999 08:30:41 -0400
Fredrik Lundh wrote:
>
> > 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.
A while ago I asked for some documentation on the Buffer
interface. I basically got silence. At this point, I
don't have a good idea what buffers are for and I don't see alot
of evidence that there *is* a design. I assume that there was
a design, but I can't see it. This whole discussion makes me
very queasy.
I'm probably just out of it, since I don't have
time to read the Python list anymore. Presumably the buffer
interface was proposed and discussed there at some distant
point in the past.
(I can't pay as much attention to this discussion as I suspect
I should, due to time constaints and due to a basic understanding
of the rational for the buffer interface. Jst now I caught a sniff
of something I find kinda repulsive. I think I hear you all talking about
beasies that hold a reference to some object's internal storage and that
have write operations so you can write directly to the objects storage
bypassing the object interfaces. I probably just imagined it.)
</whine>
Jim
--
Jim Fulton mailto:jim@digicool.com Python Powered!
Technical Director (888) 344-4332 http://www.python.org
Digital Creations http://www.digicool.com http://www.zope.org
Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission. Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.