Proper application of the buffer interface

David Ascher da at
Fri Aug 6 13:13:41 EDT 1999

On Fri, 6 Aug 1999, Skip Montanaro wrote:

> Sorry to be a numbskull, but since there is apparently little or no
> documentation for the buffer interface yet, can someone give me a thumbnail
> sketch of why we have it and what it's used for?  I can guess that there are
> some situations where using string objects as raw buffers could lead to
> misinterpretation of their contents, especially since not everything is
> US-ASCII anymore.  Beyond that, I'm not sure why there would be a
> distinction between buffers and strings.

I know of three (there may be more):

1) read/write, not just read (I'm using them to pass data to win32 calls
   which modify them, w/o new copies, etc.).

2) segmented architecture (non-contiguous strips of memory)

3) manipulating data which doesn't start its life as a PyString -- e.g. an
   mmap'ed file can expose a buffer interface, an Image can expose a
   buffer interface, a NumPy array can expose a buffer interface -- one
   can manipulate the data in those as buffers without having to copy the

--david ascher

More information about the Python-list mailing list