[Python-Dev] Bug or feature? Unicode vs t#

Paul Prescod paul@ActiveState.com
Thu, 11 Oct 2001 09:36:51 -0700


"Martin v. Loewis" wrote:
> 
>...
> 
> For Unicode objects, these are different: getcharbuffer converts the
> string using the default encoding into a character string, whereas

What is the use case for treating a Unicode object as if it were a
buffer of bytes by translating it to the default encoding?

"Python objects implemented in C can export a group of functions called
the ``buffer interface.'' These functions can be used by an object to
expose its data in a raw, byte-oriented format. Clients of the object
can use the buffer interface to access the object data directly, without
needing to copy it first."

Translating the data before handing it to the user violates the
"raw"-ness of the byte-oriented format and the principle about not
needing to copy it. It behaves quite differently than other
implementations of getcharbuffer. 

 Paul Prescod