[Python-Dev] Unifying Long Integers and Integers: baseint

"Martin v. Löwis" martin at v.loewis.de
Thu Aug 12 07:10:44 CEST 2004


Guido van Rossum wrote:
> Do we really need byte array literals at all?  I don't expect there to
> be much of a demand.  

I'm not so sure. For example, in httplib, in the line

   h.putrequest('GET', selector)

I would claim that 'GET' is a byte string, not a character string:
it is sent as-is onto the wire, which is a byte-oriented wire.

Now, it would also "work" if it were a character string, which
then gets converted to a byte string using the system default
encoding - but I believe that an application that relies on the
system default encoding is somewhat broken: Explicit is better
than implicit.

> Rather, byte arrays would eventually be returned
> by the read() method when a file is opened in binary mode.  (Isn't
> this roughly how Java does this?)

Java also supports byte arrays in the source, although they are
difficult to type:

    byte[] request = {'G', 'E', 'T'};

As for reading from streams: Java has multiple reader APIs; some
return byte strings, some character strings.

Regards,
Martin


More information about the Python-Dev mailing list