blob: 11538e26691c1820ec2531d9c461a2ae65059f05 [file] [log] [blame]
Ned Deily07a18922018-01-31 18:12:38 -05001****************************
2 What's New In Python 3.8
3****************************
4
Ned Deily07a18922018-01-31 18:12:38 -05005.. Rules for maintenance:
6
7 * Anyone can add text to this document. Do not spend very much time
8 on the wording of your changes, because your text will probably
9 get rewritten to some degree.
10
11 * The maintainer will go through Misc/NEWS periodically and add
12 changes; it's therefore more important to add your changes to
13 Misc/NEWS than to this file.
14
15 * This is not a complete list of every single change; completeness
16 is the purpose of Misc/NEWS. Some changes I consider too small
17 or esoteric to include. If such a change is added to the text,
18 I'll just remove it. (This is another reason you shouldn't spend
19 too much time on writing your addition.)
20
21 * If you want to draw your new text to the attention of the
22 maintainer, add 'XXX' to the beginning of the paragraph or
23 section.
24
25 * It's OK to just add a fragmentary note about a change. For
26 example: "XXX Describe the transmogrify() function added to the
27 socket module." The maintainer will research the change and
28 write the necessary text.
29
30 * You can comment out your additions if you like, but it's not
31 necessary (especially when a final release is some months away).
32
33 * Credit the author of a patch or bugfix. Just the name is
34 sufficient; the e-mail address isn't necessary.
35
36 * It's helpful to add the bug/patch number as a comment:
37
38 XXX Describe the transmogrify() function added to the socket
39 module.
40 (Contributed by P.Y. Developer in :issue:`12345`.)
41
42 This saves the maintainer the effort of going through the Mercurial log
43 when researching a change.
44
45This article explains the new features in Python 3.8, compared to 3.7.
46
Ned Deily45ab51c2018-02-28 13:58:38 -050047For full details, see the :ref:`changelog <changelog>`.
Ned Deily07a18922018-01-31 18:12:38 -050048
49.. note::
50
51 Prerelease users should be aware that this document is currently in draft
52 form. It will be updated substantially as Python 3.8 moves towards release,
53 so it's worth checking back even after reading earlier versions.
54
55
56Summary -- Release highlights
57=============================
58
59.. This section singles out the most important changes in Python 3.8.
60 Brevity is key.
61
62
63.. PEP-sized items next.
64
65
66
67New Features
68============
69
70
71
72Other Language Changes
73======================
74
Serhiy Storchakafe2bbb12018-03-18 09:56:52 +020075* A :keyword:`continue` statement was illegal in the :keyword:`finally` clause
76 due to a problem with the implementation. In Python 3.8 this restriction
77 was lifted.
78 (Contributed by Serhiy Storchaka in :issue:`32489`.)
79
Serhiy Storchakaa445feb2018-02-10 00:08:17 +020080* Added support of ``\N{name}`` escapes in :mod:`regular expressions <re>`.
81 (Contributed by Jonathan Eunice and Serhiy Storchaka in :issue:`30688`.)
Ned Deily07a18922018-01-31 18:12:38 -050082
83
84New Modules
85===========
86
87* None yet.
88
89
90Improved Modules
91================
92
93
94Optimizations
95=============
96
Ɓukasz Langac51d8c92018-04-03 23:06:53 -070097* The default protocol in the :mod:`pickle` module is now Protocol 4,
98 first introduced in Python 3.4. It offers better performance and smaller
99 size compared to Protocol 3 available since Python 3.0.
Ned Deily07a18922018-01-31 18:12:38 -0500100
101Build and C API Changes
102=======================
103
104
105
106Deprecated
107==========
108
109
110
111Removed
112=======
113
Brett Cannona8c34242018-04-20 14:15:40 -0700114* The ``pyvenv`` script has been removed in favor of ``python3.8 -m venv``
115 to help eliminate confusion as to what Python interpreter the ``pyvenv``
116 script is tied to. (Contributed by Brett Cannon in :issue:`25427`.)
Ned Deily07a18922018-01-31 18:12:38 -0500117
118
119Porting to Python 3.8
120=====================
121
122This section lists previously described changes and other bugfixes
123that may require changes to your code.
124
125
Serhiy Storchaka07ca9af2018-02-04 10:53:48 +0200126Changes in Python behavior
127--------------------------
128
129* Yield expressions (both ``yield`` and ``yield from`` clauses) are now disallowed
130 in comprehensions and generator expressions (aside from the iterable expression
131 in the leftmost :keyword:`for` clause).
132 (Contributed by Serhiy Storchaka in :issue:`10544`.)
133
134
Serhiy Storchaka97f1ca12018-02-01 18:49:21 +0200135Changes in the Python API
136-------------------------
137
138* The :meth:`~tkinter.ttk.Treeview.selection` method of the
139 :class:`tkinter.ttk.Treeview` class no longer takes arguments. Using it with
140 arguments for changing the selection was deprecated in Python 3.6. Use
141 specialized methods like :meth:`~tkinter.ttk.Treeview.selection_set` for
142 changing the selection. (Contributed by Serhiy Storchaka in :issue:`31508`.)
Serhiy Storchaka6c85efa52018-02-05 22:47:31 +0200143
144* A :mod:`dbm.dumb` database opened with flags ``'r'`` is now read-only.
145 :func:`dbm.dumb.open` with flags ``'r'`` and ``'w'`` no longer creates
146 a database if it does not exist.
147 (Contributed by Serhiy Storchaka in :issue:`32749`.)
Serhiy Storchaka520b7ae2018-02-22 23:33:30 +0200148
149
150CPython bytecode changes
151------------------------
152
153* The interpreter loop has been simplified by moving the logic of unrolling
154 the stack of blocks into the compiler. The compiler emits now explicit
155 instructions for adjusting the stack of values and calling the cleaning
156 up code for :keyword:`break`, :keyword:`continue` and :keyword:`return`.
157
158 Removed opcodes :opcode:`BREAK_LOOP`, :opcode:`CONTINUE_LOOP`,
159 :opcode:`SETUP_LOOP` and :opcode:`SETUP_EXCEPT`. Added new opcodes
160 :opcode:`ROT_FOUR`, :opcode:`BEGIN_FINALLY`, :opcode:`CALL_FINALLY` and
161 :opcode:`POP_FINALLY`. Changed the behavior of :opcode:`END_FINALLY`
162 and :opcode:`WITH_CLEANUP_START`.
163
164 (Contributed by Mark Shannon, Antoine Pitrou and Serhiy Storchaka in
165 :issue:`17611`.)
Serhiy Storchaka702f8f32018-03-23 14:34:35 +0200166
167* Added new opcode :opcode:`END_ASYNC_FOR` for handling exceptions raised
168 when awaiting a next item in an :keyword:`async for` loop.
169 (Contributed by Serhiy Storchaka in :issue:`33041`.)