Skip to content

Commit 69b29d1

Browse files
committed
Add a note on why Python 3
1 parent 8075250 commit 69b29d1

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

docs/why_python3.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,38 @@ Why Python 3?
1515
Unicode representation (PEP 393))
1616
- Exception chaining
1717

18+
Why are Unicode strings better on Python 3?
19+
-------------------------------------------
20+
21+
- it is not the default string type (you have to prefix the string
22+
with a u to get Unicode);
23+
24+
- it is missing some functionality, e.g. casefold;
25+
26+
- there are two distinct implementations, narrow builds and wide builds;
27+
28+
- wide builds take up to four times more memory per string as needed;
29+
30+
- narrow builds take up to two times more memory per string as needed;
31+
32+
- worse, narrow builds have very naive (possibly even "broken")
33+
handling of code points in the Supplementary Multilingual Planes.
34+
35+
The unicode string type in Python 3 is better because:
36+
37+
- it is the default string type;
38+
39+
- it includes more functionality;
40+
41+
- starting in Python 3.3, it gets rid of the distinction between
42+
narrow and wide builds;
43+
44+
- which reduces the memory overhead of strings by up to a factor
45+
of four in many cases;
46+
47+
- and fixes the issue of SMP code points.
48+
49+
(quote from a mailing list post by Steve D'Aprano on 2014-01-17).
1850

1951

2052
New features

0 commit comments

Comments
 (0)