[Image-SIG] Proper application of the buffer interface

Fred L. Drake, Jr. fdrake at acm.org
Fri Aug 6 10:17:38 EDT 1999


M.-A. Lemburg writes:
 > Wait... what's so bad about buffer(struct.pack()) ? Strings already
 > know the buffer interface, so this works just fine already.

  I think the issue is that if strings ever change to Unicode, we
don't want non-character data to ever be exposed as a string.  Using a 
buffer takes care of this and works now, allowing preparations for
further integration of Unicode to be tested gradually, rather than
having a complete meltdown from a large cutover.
  Functions which need to receive binary data will always use s#,
because s will raise TypeError if '\0' is in the string.
  The other way around is done less consistently now. The S format
character might not raise an exception if '\0' is in the data, and may 
standard functions and methods probably need to be adjusted to finish
up a Unicode integration, but I think using a buffer object for binary 
data will only avoid problems, not create them.


  -Fred

--
Fred L. Drake, Jr.	     <fdrake at acm.org>
Corporation for National Research Initiatives




More information about the Python-list mailing list