Ned Deily | 07a1892 | 2018-01-31 18:12:38 -0500 | [diff] [blame] | 1 | **************************** |
| 2 | What's New In Python 3.8 |
| 3 | **************************** |
| 4 | |
Ned Deily | 07a1892 | 2018-01-31 18:12:38 -0500 | [diff] [blame] | 5 | .. 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 | |
| 45 | This article explains the new features in Python 3.8, compared to 3.7. |
| 46 | |
Ned Deily | 45ab51c | 2018-02-28 13:58:38 -0500 | [diff] [blame] | 47 | For full details, see the :ref:`changelog <changelog>`. |
Ned Deily | 07a1892 | 2018-01-31 18:12:38 -0500 | [diff] [blame] | 48 | |
| 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 | |
| 56 | Summary -- 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 | |
| 67 | New Features |
| 68 | ============ |
| 69 | |
| 70 | |
| 71 | |
| 72 | Other Language Changes |
| 73 | ====================== |
| 74 | |
Serhiy Storchaka | fe2bbb1 | 2018-03-18 09:56:52 +0200 | [diff] [blame] | 75 | * 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 Storchaka | a445feb | 2018-02-10 00:08:17 +0200 | [diff] [blame] | 80 | * Added support of ``\N{name}`` escapes in :mod:`regular expressions <re>`. |
| 81 | (Contributed by Jonathan Eunice and Serhiy Storchaka in :issue:`30688`.) |
Ned Deily | 07a1892 | 2018-01-31 18:12:38 -0500 | [diff] [blame] | 82 | |
| 83 | |
| 84 | New Modules |
| 85 | =========== |
| 86 | |
| 87 | * None yet. |
| 88 | |
| 89 | |
| 90 | Improved Modules |
| 91 | ================ |
| 92 | |
| 93 | |
| 94 | Optimizations |
| 95 | ============= |
| 96 | |
Ćukasz Langa | c51d8c9 | 2018-04-03 23:06:53 -0700 | [diff] [blame] | 97 | * 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 Deily | 07a1892 | 2018-01-31 18:12:38 -0500 | [diff] [blame] | 100 | |
| 101 | Build and C API Changes |
| 102 | ======================= |
| 103 | |
| 104 | |
| 105 | |
| 106 | Deprecated |
| 107 | ========== |
| 108 | |
| 109 | |
| 110 | |
| 111 | Removed |
| 112 | ======= |
| 113 | |
Brett Cannon | a8c3424 | 2018-04-20 14:15:40 -0700 | [diff] [blame] | 114 | * 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 Deily | 07a1892 | 2018-01-31 18:12:38 -0500 | [diff] [blame] | 117 | |
| 118 | |
| 119 | Porting to Python 3.8 |
| 120 | ===================== |
| 121 | |
| 122 | This section lists previously described changes and other bugfixes |
| 123 | that may require changes to your code. |
| 124 | |
| 125 | |
Serhiy Storchaka | 07ca9af | 2018-02-04 10:53:48 +0200 | [diff] [blame] | 126 | Changes 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 Storchaka | 97f1ca1 | 2018-02-01 18:49:21 +0200 | [diff] [blame] | 135 | Changes 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 Storchaka | 6c85efa5 | 2018-02-05 22:47:31 +0200 | [diff] [blame] | 143 | |
| 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 Storchaka | 520b7ae | 2018-02-22 23:33:30 +0200 | [diff] [blame] | 148 | |
| 149 | |
| 150 | CPython 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 Storchaka | 702f8f3 | 2018-03-23 14:34:35 +0200 | [diff] [blame] | 166 | |
| 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`.) |