

Moving to Python 3 - bitsai
http://lwn.net/SubscriberLink/426906/9707a799b4d38e79/

======
IgorPartola
There is _fundamental_ a difference between Unicode and UTF-8/16/32. Unicode
says nothing at all about how strings should be stored in memory. It is just a
set of symbols and code-points. On the other hand, UTF-8/16/32 are
implementations of Unicode. See
<http://en.wikipedia.org/wiki/Unicode#Mapping_and_encodings> for others.

Statements like "first 256 code points in Unicode map to Latin-1" make little
sense. They are true if you s/Unicode/UTF-8/g. However, they are not true for
other encodings such as ones that use 2 or 4 bytes per character. There 'abcd'
is not 4 bytes, but 8 or 16.

~~~
jmillikin
> _Statements like "first 256 code points in Unicode map to Latin-1" make
> little sense._

That's not true. Latin-1 is both a character set _and_ an encoding, so "the
first 256 Unicode code points map to the corresponding Latin-1 characters" is
a reasonable statement.

You can also say "the first 128 Unicode code points, when encoded in UTF-8,
are equal to the corresponding Latin-1 encoding".

~~~
IgorPartola
My point is that in Python land it is silly to call u"" strings, "Unicode"
strings. Unicode strings are strings in UTF-8/16/32 and a bunch of lesser-used
encodings. For that matter "" could be used as a Unicode string as long as
it's only ASCII. What the docs should be talking about is ASCII vs UTF-16, not
ASCII/Latin-1 vs Unicode. This starts making a difference when questions like
"How much memory is consumed by this string?" or "What characters can I not
store in Python?" are asked. In this light, Python 3 makes a big improvement:
it has immutable byte arrays and it has encoded strings.

------
samuel
"Python 3 is unarguably a better language than Python 2."

I would say that's unarguably marginally better. What provides Python 3 that I
miss in Python 2? For me nothing at all. Ok, dealing with Unicode it's easier.
So what? Optional type annotations, that's something I would miss.

~~~
callahad
Unarguably marginally better is still unarguably better.

Set and dict comprehensions are pretty rad. Ordered dicts are useful. The new
unittest module is great.

Of course, all of these have been back-ported to 2.7, but even if they hadn't,
Python 2 is still a very capable language. Don't have dict comprehensions?
Well, you can build an equivalent loop without too much difficulty, and you're
used to doing that.

So there's not a great value proposition when it comes to moving from Python 2
to Python 3. You're used to working around the warts, and the workarounds
aren't that painful. But what about going from 3 to 2? Once you're used to
range() being efficient, to dict comprehensions, to a cleaned up stdlib, and
to sane Unicode handling? You won't be crippled, but I'm fairly certain you
won't find it quite as pleasant.

I believe that's the measure that matters, in the long run. Would the old
thing feel worse than the new thing, from the perspective of the new thing? If
the answer is, to any degree, unambiguously "yes," then it only makes sense to
plan on making that move.

~~~
masklinn
> Well, you can build an equivalent loop without too much difficulty, and
> you're used to doing that.

You can build an equivalent list or generator comprehension (just generate
tuples and feed that to `dict`). It's just ugly.

~~~
glenjamin
I believe that was the OP's point.

------
runjake
Two words: Django.

Ok, that's only one word, but that's my only hold-up for moving to Python3.

