[Image-SIG] Proper application of the buffer interface
David Ascher
da at ski.org
Fri Aug 6 12:36:18 EDT 1999
On Fri, 6 Aug 1999, M.-A. Lemburg wrote:
> Fred L. Drake, Jr. wrote:
> >
> > David Ascher writes:
> > > Would it also make sense to make struct.pack() return a buffer object
> > > instead of a string?
> >
> > Sounds like it to me. If Guido agrees, I can make the changes.
>
> Wait... what's so bad about buffer(struct.pack()) ? Strings already
> know the buffer interface, so this works just fine already.
It's not terrible, but it seems suboptimal. It strikes me that
struct.pack() explicitely shouldn't create strings, it should create
arrays of bytes. Let's ask the question the other way -- what's wrong
with having struct.pack() return buffers instead of strings? The only
thing I can think of is that type(struct.pack()) is no longer StringType.
Maybe that's enough to push the change to 2.0, I'm not sure either way.
--david
More information about the Python-list
mailing list