[Python-Dev] methods on the bytes object

Josiah Carlson jcarlson at uci.edu
Sun Apr 30 20:30:05 CEST 2006


"Martin v. Löwis" <martin at v.loewis.de> wrote:
> Josiah Carlson wrote:
> > Specifically in the case of bytes.join(), the current common use-case of
> > <literal>.join(...) would become something similar to
> > bytes(<literal>).join(...), unless bytes objects got a syntax... Or
> > maybe I'm missing something?
> 
> I think what you are missing is that algorithms that currently operate
> on byte strings should be reformulated to operate on character strings,
> not reformulated to operate on bytes objects.

By "character strings" can I assume you mean unicode strings which
contain data, and not some new "character string" type? I know I must
have missed some conversation. I was under the impression that in Py3k:

Python 1.x and 2.x str -> mutable bytes object
Python 2.x unicode -> str

I was also under the impression that str.encode(...) -> bytes,
bytes.decode(...) -> str, and that there would be some magical argument
to pass to the file or open open(fn, 'rb', magical_parameter).read() ->
bytes.

I mention this because I do binary data handling, some ''.join(...) for
IO buffers as Guido mentioned (because it is the fastest string
concatenation available in Python 2.x), and from this particular
conversation, it seems as though Python 3.x is going to lose
some expressiveness and power.

 - Josiah



More information about the Python-Dev mailing list