blob: 29d370cc8a284f4849b4d222e22ff619ec048a57 [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
Nick Coghlan16eb3bc2018-06-20 21:25:01 +100070Parallel filesystem cache for compiled bytecode files
71-----------------------------------------------------
72
73The new :envvar:`PYTHONPYCACHEPREFIX` setting (also available as
74:option:`-X` ``pycache_prefix``) configures the implicit bytecode
75cache to use a separate parallel filesystem tree, rather than
76the default ``__pycache__`` subdirectories within each source
77directory.
78
79The location of the cache is reported in :data:`sys.pycache_prefix`
80(:const:`None` indicates the default location in ``__pycache__``
81subdirectories).
82
83(Contributed by Carl Meyer in :issue:`33499`.)
Ned Deily07a18922018-01-31 18:12:38 -050084
85
86Other Language Changes
87======================
88
Serhiy Storchakafe2bbb12018-03-18 09:56:52 +020089* A :keyword:`continue` statement was illegal in the :keyword:`finally` clause
90 due to a problem with the implementation. In Python 3.8 this restriction
91 was lifted.
92 (Contributed by Serhiy Storchaka in :issue:`32489`.)
93
Serhiy Storchakab2e20252018-10-20 00:46:31 +030094* The :class:`int` type now has a new :meth:`~int.as_integer_ratio` method
95 compatible with the existing :meth:`float.as_integer_ratio` method.
Lisa Roach5ac70432018-09-13 23:56:23 -070096 (Contributed by Lisa Roach in :issue:`33073`.)
97
Serhiy Storchakaa445feb2018-02-10 00:08:17 +020098* Added support of ``\N{name}`` escapes in :mod:`regular expressions <re>`.
99 (Contributed by Jonathan Eunice and Serhiy Storchaka in :issue:`30688`.)
Ned Deily07a18922018-01-31 18:12:38 -0500100
Rémi Lapeyre6531bf62018-11-06 01:38:54 +0100101* Dict and dictviews are now iterable in reversed insertion order using
102 :func:`reversed`. (Contributed by Rémi Lapeyre in :issue:`33462`.)
103
Benjamin Petersonc9a71dd2018-09-12 17:14:39 -0700104* The syntax allowed for keyword names in function calls was further
105 restricted. In particular, ``f((keyword)=arg)`` is no longer allowed. It was
106 never intended to permit more than a bare name on the left-hand side of a
107 keyword argument assignment term. See :issue:`34641`.
Ned Deily07a18922018-01-31 18:12:38 -0500108
jChapman8fabae32018-09-22 21:13:10 -0400109* Iterable unpacking is now allowed without parentheses in :keyword:`yield`
110 and :keyword:`return` statements.
111 (Contributed by David Cuthbert and Jordan Chapman in :issue:`32117`.)
112
Serhiy Storchaka65439122018-10-19 17:42:06 +0300113* A backslash-character pair that is not a valid escape sequence generates
114 a :exc:`DeprecationWarning` since Python 3.6. In Python 3.8 it generates
115 a :exc:`SyntaxWarning` instead.
116 (Contributed by Serhiy Storchaka in :issue:`32912`.)
117
Serhiy Storchaka62e44812019-02-16 08:12:19 +0200118* The compiler now produces a :exc:`SyntaxWarning` in some cases when a comma
119 is missed before tuple or list. For example::
120
121 data = [
122 (1, 2, 3) # oops, missing comma!
123 (4, 5, 6)
124 ]
125
126 (Contributed by Serhiy Storchaka in :issue:`15248`.)
127
Paul Ganssled9503c32019-02-08 11:02:00 -0500128* Arithmetic operations between subclasses of :class:`datetime.date` or
129 :class:`datetime.datetime` and :class:`datetime.timedelta` objects now return
130 an instance of the subclass, rather than the base class. This also affects
131 the return type of operations whose implementation (directly or indirectly)
132 uses :class:`datetime.timedelta` arithmetic, such as
133 :meth:`datetime.datetime.astimezone`.
134 (Contributed by Paul Ganssle in :issue:`32417`.)
135
Gregory P. Smith06babb22019-02-23 10:43:49 -0800136* When the Python interpreter is interrupted by Ctrl-C (SIGINT) and the
137 resulting :exc:`KeyboardInterrupt` exception is not caught, the Python process
138 now exits via a SIGINT signal or with the correct exit code such that the
139 calling process can detect that it died due to a Ctrl-C. Shells on POSIX
140 and Windows use this to properly terminate scripts in interactive sessions.
141 (Contributed by Google via Gregory P. Smith in :issue:`1054041`.)
142
Serhiy Storchaka65439122018-10-19 17:42:06 +0300143
Ned Deily07a18922018-01-31 18:12:38 -0500144New Modules
145===========
146
147* None yet.
148
149
150Improved Modules
151================
152
Raymond Hettinger0bb4bdf2019-01-31 00:59:50 -0800153* The :meth:`_asdict()` method for :func:`collections.namedtuple` now returns
154 a :class:`dict` instead of a :class:`collections.OrderedDict`. This works because
155 regular dicts have guaranteed ordering in since Python 3.7. If the extra
156 features of :class:`OrderedDict` are required, the suggested remediation is
157 to cast the result to the desired type: ``OrderedDict(nt._asdict())``.
158 (Contributed by Raymond Hettinger in :issue:`35864`.)
159
Benjamin Peterson738c19f2019-03-09 16:25:55 -0800160* The :mod:`unicodedata` module has been upgraded to use the `Unicode 12.0.0
161 <http://blog.unicode.org/2019/03/announcing-unicode-standard-version-120.html>`_
162 release.
163
Raymond Hettinger0bb4bdf2019-01-31 00:59:50 -0800164
Victor Stinner6ea29c52018-09-25 08:27:08 -0700165asyncio
166-------
167
168On Windows, the default event loop is now :class:`~asyncio.ProactorEventLoop`.
169
Terry Jan Reedyfdcb5ae2018-09-25 12:45:27 -0400170
Steve Dower2438cdf2019-03-29 16:37:16 -0700171ctypes
172------
173
174On Windows, :class:`~ctypes.CDLL` and subclasses now accept a *winmode* parameter
175to specify flags for the underlying ``LoadLibraryEx`` call. The default flags are
176set to only load DLL dependencies from trusted locations, including the path
177where the DLL is stored (if a full or partial path is used to load the initial
178DLL) and paths added by :func:`~os.add_dll_directory`.
179
180
Cheryl Sabella637a33b2018-11-07 09:12:20 -0500181gettext
182-------
183
184Added :func:`~gettext.pgettext` and its variants.
185(Contributed by Franz Glasner, Éric Araujo, and Cheryl Sabella in :issue:`2504`.)
186
Raymond Hettingerd1e768a2019-03-25 13:01:13 -0700187inspect
188-------
189
190The :func:`inspect.getdoc` function can now find docstrings for ``__slots__``
191if that attribute is a :class:`dict` where the values are docstrings.
192This provides documentation options similar to what we already have
193for :func:`property`, :func:`classmethod`, and :func:`staticmethod`::
194
195 class AudioClip:
196 __slots__ = {'bit_rate': 'expressed in kilohertz to one decimal place',
197 'duration': 'in seconds, rounded up to an integer'}
198 def __init__(self, bit_rate, duration):
199 self.bit_rate = round(bit_rate / 1000.0, 1)
200 self.duration = ceil(duration)
Pablo Galindo175421b2019-02-23 03:02:06 +0000201
202gc
203--
204
205:func:`~gc.get_objects` can now receive an optional *generation* parameter
206indicating a generation to get objects from. Contributed in
207:issue:`36016` by Pablo Galindo.
208
209
guoci0e7497c2018-11-07 04:50:23 -0500210gzip
211----
212
213Added the *mtime* parameter to :func:`gzip.compress` for reproducible output.
214(Contributed by Guo Ci Teo in :issue:`34898`.)
215
216
Terry Jan Reedyfdcb5ae2018-09-25 12:45:27 -0400217idlelib and IDLE
218----------------
219
220Output over N lines (50 by default) is squeezed down to a button.
221N can be changed in the PyShell section of the General page of the
222Settings dialog. Fewer, but possibly extra long, lines can be squeezed by
223right clicking on the output. Squeezed output can be expanded in place
224by double-clicking the button or into the clipboard or a separate window
225by right-clicking the button. (Contributed by Tal Einat in :issue:`1529353`.)
226
227The changes above have been backported to 3.7 maintenance releases.
228
229
HongWeipengf1944792018-11-07 18:09:32 +0800230json.tool
231---------
232
233Add option ``--json-lines`` to parse every input line as separate JSON object.
234(Contributed by Weipeng Hong in :issue:`31553`.)
235
Pablo Galindobc098512019-02-07 07:04:02 +0000236
237math
238----
239
Raymond Hettinger3ff59622019-02-16 11:00:42 -0800240Added new function :func:`math.dist` for computing Euclidean distance
241between two points. (Contributed by Raymond Hettinger in :issue:`33089`.)
242
243Expanded the :func:`math.hypot` function to handle multiple dimensions.
244Formerly, it only supported the 2-D case.
245(Contributed by Raymond Hettinger in :issue:`33089`.)
246
Pablo Galindobc098512019-02-07 07:04:02 +0000247Added new function, :func:`math.prod`, as analogous function to :func:`sum`
248that returns the product of a 'start' value (default: 1) times an iterable of
Raymond Hettinger3ff59622019-02-16 11:00:42 -0800249numbers. (Contributed by Pablo Galindo in :issue:`35606`)
Pablo Galindobc098512019-02-07 07:04:02 +0000250
Steve Dower2438cdf2019-03-29 16:37:16 -0700251os
252--
253
254Added new function :func:`~os.add_dll_directory` on Windows for providing
255additional search paths for native dependencies when importing extension
256modules or loading DLLs using :mod:`ctypes`.
257
Pablo Galindobc098512019-02-07 07:04:02 +0000258
Serhiy Storchaka0185f342018-09-18 11:28:51 +0300259os.path
260-------
261
262:mod:`os.path` functions that return a boolean result like
263:func:`~os.path.exists`, :func:`~os.path.lexists`, :func:`~os.path.isdir`,
264:func:`~os.path.isfile`, :func:`~os.path.islink`, and :func:`~os.path.ismount`
265now return ``False`` instead of raising :exc:`ValueError` or its subclasses
266:exc:`UnicodeEncodeError` and :exc:`UnicodeDecodeError` for paths that contain
267characters or bytes unrepresentable at the OS level.
268(Contributed by Serhiy Storchaka in :issue:`33721`.)
269
Steve Dower8ef864d2019-03-12 15:15:26 -0700270:func:`~os.path.expanduser` on Windows now prefers the :envvar:`USERPROFILE`
271environment variable and does not use :envvar:`HOME`, which is not normally set
272for regular user accounts.
273
Serhiy Storchakab232df92018-10-30 13:22:42 +0200274
275ncurses
276-------
277
278Added a new variable holding structured version information for the
279underlying ncurses library: :data:`~curses.ncurses_version`.
280(Contributed by Serhiy Storchaka in :issue:`31680`.)
281
282
Serhiy Storchaka0185f342018-09-18 11:28:51 +0300283pathlib
284-------
285
286:mod:`pathlib.Path` methods that return a boolean result like
287:meth:`~pathlib.Path.exists()`, :meth:`~pathlib.Path.is_dir()`,
288:meth:`~pathlib.Path.is_file()`, :meth:`~pathlib.Path.is_mount()`,
289:meth:`~pathlib.Path.is_symlink()`, :meth:`~pathlib.Path.is_block_device()`,
290:meth:`~pathlib.Path.is_char_device()`, :meth:`~pathlib.Path.is_fifo()`,
291:meth:`~pathlib.Path.is_socket()` now return ``False`` instead of raising
292:exc:`ValueError` or its subclass :exc:`UnicodeEncodeError` for paths that
293contain characters unrepresentable at the OS level.
294(Contributed by Serhiy Storchaka in :issue:`33721`.)
295
jab9e00d9e2018-12-28 13:03:40 -0500296
297shutil
298------
299
300:func:`shutil.copytree` now accepts a new ``dirs_exist_ok`` keyword argument.
301(Contributed by Josh Bronson in :issue:`20849`.)
302
CAM Gerlach89a89442019-04-06 23:47:49 -0500303:func:`shutil.make_archive` now defaults to the modern pax (POSIX.1-2001)
304format for new archives to improve portability and standards conformance,
305inherited from the corresponding change to the :mod:`tarfile` module.
306(Contributed by C.A.M. Gerlach in :issue:`30661`.)
307
jab9e00d9e2018-12-28 13:03:40 -0500308
Christian Heimes9fb051f2018-09-23 08:32:31 +0200309ssl
310---
311
312Added :attr:`SSLContext.post_handshake_auth` to enable and
313:meth:`ssl.SSLSocket.verify_client_post_handshake` to initiate TLS 1.3
314post-handshake authentication.
315(Contributed by Christian Heimes in :issue:`34670`.)
316
Raymond Hettinger47d99872019-02-21 15:06:29 -0800317
318statistics
319----------
320
321Added :func:`statistics.fmean` as a faster, floating point variant of
322:func:`statistics.mean()`. (Contributed by Raymond Hettinger and
323Steven D'Aprano in :issue:`35904`.)
324
Raymond Hettinger6463ba32019-04-07 09:20:03 -0700325Added :func:`statistics.geometric_mean()`
326(Contributed by Raymond Hettinger in :issue:`27181`.)
327
Raymond Hettingerfc06a192019-03-12 00:43:27 -0700328Added :func:`statistics.multimode` that returns a list of the most
329common values. (Contributed by Raymond Hettinger in :issue:`35892`.)
330
Raymond Hettinger11c79532019-02-23 14:44:07 -0800331Added :class:`statistics.NormalDist`, a tool for creating
332and manipulating normal distributions of a random variable.
333(Contributed by Raymond Hettinger in :issue:`36018`.)
334
335::
336
337 >>> temperature_feb = NormalDist.from_samples([4, 12, -3, 2, 7, 14])
338 >>> temperature_feb
339 NormalDist(mu=6.0, sigma=6.356099432828281)
340
341 >>> temperature_feb.cdf(3) # Chance of being under 3 degrees
342 0.3184678262814532
343 >>> # Relative chance of being 7 degrees versus 10 degrees
344 >>> temperature_feb.pdf(7) / temperature_feb.pdf(10)
345 1.2039930378537762
346
347 >>> el_nino = NormalDist(4, 2.5)
348 >>> temperature_feb += el_nino # Add in a climate effect
349 >>> temperature_feb
350 NormalDist(mu=10.0, sigma=6.830080526611674)
351
352 >>> temperature_feb * (9/5) + 32 # Convert to Fahrenheit
353 NormalDist(mu=50.0, sigma=12.294144947901014)
354 >>> temperature_feb.samples(3) # Generate random samples
355 [7.672102882379219, 12.000027119750287, 4.647488369766392]
356
Raymond Hettinger47d99872019-02-21 15:06:29 -0800357
CAM Gerlache680c3d2019-03-21 09:44:51 -0500358tarfile
359-------
360
361The :mod:`tarfile` module now defaults to the modern pax (POSIX.1-2001)
362format for new archives, instead of the previous GNU-specific one.
363This improves cross-platform portability with a consistent encoding (UTF-8)
364in a standardized and extensible format, and offers several other benefits.
365(Contributed by C.A.M. Gerlach in :issue:`36268`.)
366
367
Tal Einatdfba1f62018-10-24 10:20:05 +0300368tokenize
369--------
370
371The :mod:`tokenize` module now implicitly emits a ``NEWLINE`` token when
372provided with input that does not have a trailing new line. This behavior
373now matches what the C tokenizer does internally.
374(Contributed by Ammar Askar in :issue:`33899`.)
375
Juliette Monselaf5658a2018-10-08 18:29:24 +0200376tkinter
377-------
378
379Added methods :meth:`~tkinter.Spinbox.selection_from`,
380:meth:`~tkinter.Spinbox.selection_present`,
381:meth:`~tkinter.Spinbox.selection_range` and
382:meth:`~tkinter.Spinbox.selection_to`
383in the :class:`tkinter.Spinbox` class.
384(Contributed by Juliette Monsel in :issue:`34829`.)
385
Juliette Monselbf034712018-10-12 18:44:10 +0200386Added method :meth:`~tkinter.Canvas.moveto`
387in the :class:`tkinter.Canvas` class.
388(Contributed by Juliette Monsel in :issue:`23831`.)
389
Zackery Spytz50866e92019-04-05 04:17:13 -0600390The :class:`tkinter.PhotoImage` class now has
391:meth:`~tkinter.PhotoImage.transparency_get` and
392:meth:`~tkinter.PhotoImage.transparency_set` methods. (Contributed by
393Zackery Spytz in :issue:`25451`.)
394
Joannah Nanjekye572168a2019-01-10 19:56:38 +0300395time
396----
397
398Added new clock :data:`~time.CLOCK_UPTIME_RAW` for macOS 10.12.
399(Contributed by Joannah Nanjekye in :issue:`35702`.)
400
Max Bélanger2810dd72018-11-04 15:58:24 -0800401unicodedata
402-----------
403
404* New function :func:`~unicodedata.is_normalized` can be used to verify a string
405 is in a specific normal form. (Contributed by Max Belanger and David Euresti in
406 :issue:`32285`).
407
Lisa Roach0f221d02018-11-08 18:34:33 -0800408unittest
409--------
410
411* Added :func:`~unittest.addModuleCleanup()` and
412 :meth:`~unittest.TestCase.addClassCleanup()` to unittest to support
413 cleanups for :func:`~unittest.setUpModule()` and
414 :meth:`~unittest.TestCase.setUpClass()`.
415 (Contributed by Lisa Roach in :issue:`24412`.)
416
Brett Cannond64ee1a2018-09-21 15:27:26 -0700417venv
418----
419
420* :mod:`venv` now includes an ``Activate.ps1`` script on all platforms for
421 activating virtual environments under PowerShell Core 6.1.
422 (Contributed by Brett Cannon in :issue:`32718`.)
423
Christian Heimes17b1d5d2018-09-23 09:50:25 +0200424xml
425---
426
427* As mitigation against DTD and external entity retrieval, the
Andrés Delfinoca682612018-11-07 14:29:14 -0300428 :mod:`xml.dom.minidom` and :mod:`xml.sax` modules no longer process
Christian Heimes17b1d5d2018-09-23 09:50:25 +0200429 external entities by default.
430 (Contributed by Christian Heimes in :issue:`17239`.)
431
432
Ned Deily07a18922018-01-31 18:12:38 -0500433Optimizations
434=============
435
Victor Stinner9daecf32019-01-16 00:02:35 +0100436* The :mod:`subprocess` module can now use the :func:`os.posix_spawn` function
437 in some cases for better performance. Currently, it is only used on macOS
438 and Linux (using glibc 2.24 or newer) if all these conditions are met:
439
440 * *close_fds* is false;
Victor Stinnerf6243ac2019-01-23 19:00:39 +0100441 * *preexec_fn*, *pass_fds*, *cwd* and *start_new_session* parameters
442 are not set;
Victor Stinner8c349562019-01-16 23:38:06 +0100443 * the *executable* path contains a directory.
Victor Stinner9daecf32019-01-16 00:02:35 +0100444
Giampaolo Rodola4a172cc2018-06-12 23:04:50 +0200445* :func:`shutil.copyfile`, :func:`shutil.copy`, :func:`shutil.copy2`,
446 :func:`shutil.copytree` and :func:`shutil.move` use platform-specific
Giampaolo Rodolac7f02a92018-06-19 08:27:29 -0700447 "fast-copy" syscalls on Linux, macOS and Solaris in order to copy the file
448 more efficiently.
Giampaolo Rodola4a172cc2018-06-12 23:04:50 +0200449 "fast-copy" means that the copying operation occurs within the kernel,
450 avoiding the use of userspace buffers in Python as in
451 "``outfd.write(infd.read())``".
Giampaolo Rodolac7f02a92018-06-19 08:27:29 -0700452 On Windows :func:`shutil.copyfile` uses a bigger default buffer size (1 MiB
453 instead of 16 KiB) and a :func:`memoryview`-based variant of
454 :func:`shutil.copyfileobj` is used.
455 The speedup for copying a 512 MiB file within the same partition is about
456 +26% on Linux, +50% on macOS and +40% on Windows. Also, much less CPU cycles
457 are consumed.
458 See :ref:`shutil-platform-dependent-efficient-copy-operations` section.
Mariatta16501b72018-12-06 21:59:42 -0800459 (Contributed by Giampaolo Rodola' in :issue:`33671`.)
Giampaolo Rodola4a172cc2018-06-12 23:04:50 +0200460
Giampaolo Rodola19c46a42018-11-12 06:18:15 -0800461* :func:`shutil.copytree` uses :func:`os.scandir` function and all copy
462 functions depending from it use cached :func:`os.stat` values. The speedup
463 for copying a directory with 8000 files is around +9% on Linux, +20% on
464 Windows and +30% on a Windows SMB share. Also the number of :func:`os.stat`
465 syscalls is reduced by 38% making :func:`shutil.copytree` especially faster
466 on network filesystems. (Contributed by Giampaolo Rodola' in :issue:`33695`.)
467
Łukasz Langac51d8c92018-04-03 23:06:53 -0700468* The default protocol in the :mod:`pickle` module is now Protocol 4,
469 first introduced in Python 3.4. It offers better performance and smaller
470 size compared to Protocol 3 available since Python 3.0.
Ned Deily07a18922018-01-31 18:12:38 -0500471
INADA Naokid5c875b2018-07-11 17:42:49 +0900472* Removed one ``Py_ssize_t`` member from ``PyGC_Head``. All GC tracked
473 objects (e.g. tuple, list, dict) size is reduced 4 or 8 bytes.
474 (Contributed by Inada Naoki in :issue:`33597`)
475
Tal Einat54752532018-09-10 16:11:04 +0300476* :class:`uuid.UUID` now uses ``__slots__`` to reduce its memory footprint.
Tal Einat54752532018-09-10 16:11:04 +0300477
Raymond Hettinger63fa1cf2019-02-16 12:02:22 -0800478* Improved performance of :func:`operator.itemgetter` by 33%. Optimized
479 argument handling and added a fast path for the common case of a single
480 non-negative integer index into a tuple (which is the typical use case in
481 the standard library). (Contributed by Raymond Hettinger in
482 :issue:`35664`.)
483
484* Sped-up field lookups in :func:`collections.namedtuple`. They are now more
485 than two times faster, making them the fastest form of instance variable
486 lookup in Python. (Contributed by Raymond Hettinger, Pablo Galindo, and
Joe Jevnikf36f8922019-02-21 16:00:40 -0500487 Joe Jevnik, Serhiy Storchaka in :issue:`32492`.)
Raymond Hettinger63fa1cf2019-02-16 12:02:22 -0800488
Pablo Galindoc61e2292018-10-28 22:03:18 +0000489* The :class:`list` constructor does not overallocate the internal item buffer
490 if the input iterable has a known length (the input implements ``__len__``).
Raymond Hettingere1823182019-02-16 12:47:48 -0800491 This makes the created list 12% smaller on average. (Contributed by
492 Raymond Hettinger and Pablo Galindo in :issue:`33234`.)
Pablo Galindoc61e2292018-10-28 22:03:18 +0000493
Stefan Behneld8b9e1f2019-02-20 18:29:24 +0100494* Doubled the speed of class variable writes. When a non-dunder attribute
495 was updated, there was an unnecessary call to update slots.
496 (Contributed by Stefan Behnel, Pablo Galindo Salgado, Raymond Hettinger,
497 Neil Schemenauer, and Serhiy Storchaka in :issue:`36012`.)
498
Serhiy Storchaka31913912019-03-14 10:32:22 +0200499* Reduced an overhead of converting arguments passed to many builtin functions
500 and methods. This sped up calling some simple builtin functions and
501 methods up to 20--50%. (Contributed by Serhiy Storchaka in :issue:`23867`,
502 :issue:`35582` and :issue:`36127`.)
503
Serhiy Storchakaceeef102018-06-15 11:09:43 +0300504
Ned Deily07a18922018-01-31 18:12:38 -0500505Build and C API Changes
506=======================
507
Victor Stinnerbf4ac2d2019-01-22 17:39:03 +0100508* The :c:func:`PyByteArray_Init` and :c:func:`PyByteArray_Fini` functions have
509 been removed. They did nothing since Python 2.7.4 and Python 3.2.0, were
510 excluded from the limited API (stable ABI), and were not documented.
511
Serhiy Storchakaceeef102018-06-15 11:09:43 +0300512* The result of :c:func:`PyExceptionClass_Name` is now of type
513 ``const char *`` rather of ``char *``.
514 (Contributed by Serhiy Storchaka in :issue:`33818`.)
Ned Deily07a18922018-01-31 18:12:38 -0500515
Antoine Pitrou961d54c2018-07-16 19:03:03 +0200516* The duality of ``Modules/Setup.dist`` and ``Modules/Setup`` has been
517 removed. Previously, when updating the CPython source tree, one had
518 to manually copy ``Modules/Setup.dist`` (inside the source tree) to
519 ``Modules/Setup`` (inside the build tree) in order to reflect any changes
520 upstream. This was of a small benefit to packagers at the expense of
521 a frequent annoyance to developers following CPython development, as
522 forgetting to copy the file could produce build failures.
523
524 Now the build system always reads from ``Modules/Setup`` inside the source
525 tree. People who want to customize that file are encouraged to maintain
526 their changes in a git fork of CPython or as patch files, as they would do
527 for any other change to the source tree.
528
529 (Contributed by Antoine Pitrou in :issue:`32430`.)
530
Serhiy Storchaka6a44f6e2019-02-25 17:57:58 +0200531* Functions that convert Python number to C integer like
532 :c:func:`PyLong_AsLong` and argument parsing functions like
533 :c:func:`PyArg_ParseTuple` with integer converting format units like ``'i'``
534 will now use the :meth:`~object.__index__` special method instead of
535 :meth:`~object.__int__`, if available. The deprecation warning will be
536 emitted for objects with the ``__int__()`` method but without the
537 ``__index__()`` method (like :class:`~decimal.Decimal` and
538 :class:`~fractions.Fraction`). :c:func:`PyNumber_Check` will now return
539 ``1`` for objects implementing ``__index__()``.
540 (Contributed by Serhiy Storchaka in :issue:`36048`.)
541
Eddie Elizondo364f0b02019-03-27 07:52:18 -0400542* Heap-allocated type objects will now increase their reference count
543 in :c:func:`PyObject_Init` (and its parallel macro ``PyObject_INIT``)
544 instead of in :c:func:`PyType_GenericAlloc`. Types that modify instance
545 allocation or deallocation may need to be adjusted.
546 (Contributed by Eddie Elizondo in :issue:`35810`.)
547
Ned Deily07a18922018-01-31 18:12:38 -0500548
549Deprecated
550==========
551
Serhiy Storchaka02ec92f2018-07-24 12:03:34 +0300552* Deprecated methods ``getchildren()`` and ``getiterator()`` in
553 the :mod:`~xml.etree.ElementTree` module emit now a
554 :exc:`DeprecationWarning` instead of :exc:`PendingDeprecationWarning`.
555 They will be removed in Python 3.9.
556 (Contributed by Serhiy Storchaka in :issue:`29209`.)
Ned Deily07a18922018-01-31 18:12:38 -0500557
Elvis Pranskevichus22d25082018-07-30 11:42:43 +0100558* Passing an object that is not an instance of
559 :class:`concurrent.futures.ThreadPoolExecutor` to
Yury Selivanov7c7605f2018-09-11 09:54:40 -0700560 :meth:`asyncio.loop.set_default_executor()` is
Elvis Pranskevichus22d25082018-07-30 11:42:43 +0100561 deprecated and will be prohibited in Python 3.9.
562 (Contributed by Elvis Pranskevichus in :issue:`34075`.)
563
Berker Peksagef8861c2018-08-21 17:58:49 +0300564* The :meth:`__getitem__` methods of :class:`xml.dom.pulldom.DOMEventStream`,
565 :class:`wsgiref.util.FileWrapper` and :class:`fileinput.FileInput` have been
566 deprecated.
567
568 Implementations of these methods have been ignoring their *index* parameter,
569 and returning the next item instead.
570
571 (Contributed by Berker Peksag in :issue:`9372`.)
572
Raymond Hettingerf7b57df2019-03-18 09:53:56 -0700573* The :class:`typing.NamedTuple` class has deprecated the ``_field_types``
574 attribute in favor of the ``__annotations__`` attribute which has the same
575 information. (Contributed by Raymond Hettinger in :issue:`36320`.)
576
Serhiy Storchaka3f228112018-09-27 17:42:37 +0300577* :mod:`ast` classes ``Num``, ``Str``, ``Bytes``, ``NameConstant`` and
578 ``Ellipsis`` are considered deprecated and will be removed in future Python
579 versions. :class:`~ast.Constant` should be used instead.
580 (Contributed by Serhiy Storchaka in :issue:`32892`.)
581
Serhiy Storchakafec35c92018-10-27 08:00:41 +0300582* The following functions and methods are deprecated in the :mod:`gettext`
583 module: :func:`~gettext.lgettext`, :func:`~gettext.ldgettext`,
584 :func:`~gettext.lngettext` and :func:`~gettext.ldngettext`.
585 They return encoded bytes, and it's possible that you will get unexpected
586 Unicode-related exceptions if there are encoding problems with the
587 translated strings. It's much better to use alternatives which return
588 Unicode strings in Python 3. These functions have been broken for a long time.
589
590 Function :func:`~gettext.bind_textdomain_codeset`, methods
591 :meth:`~gettext.NullTranslations.output_charset` and
592 :meth:`~gettext.NullTranslations.set_output_charset`, and the *codeset*
593 parameter of functions :func:`~gettext.translation` and
594 :func:`~gettext.install` are also deprecated, since they are only used for
595 for the ``l*gettext()`` functions.
596
597 (Contributed by Serhiy Storchaka in :issue:`33710`.)
598
Dong-hee Na89669ff2019-01-17 21:14:45 +0900599* The :meth:`~threading.Thread.isAlive()` method of :class:`threading.Thread` has been deprecated.
600 (Contributed by Dong-hee Na in :issue:`35283`.)
Ned Deily07a18922018-01-31 18:12:38 -0500601
Serhiy Storchaka6a44f6e2019-02-25 17:57:58 +0200602* Many builtin and extension functions that take integer arguments will
603 now emit a deprecation warning for :class:`~decimal.Decimal`\ s,
604 :class:`~fractions.Fraction`\ s and any other objects that can be converted
605 to integers only with a loss (e.g. that have the :meth:`~object.__int__`
606 method but do not have the :meth:`~object.__index__` method). In future
607 version they will be errors.
608 (Contributed by Serhiy Storchaka in :issue:`36048`.)
609
Serhiy Storchaka42a139e2019-04-01 09:16:35 +0300610* Deprecated passing the following arguments as keyword arguments:
611
612 - *func* in :func:`functools.partialmethod`, :func:`weakref.finalize`,
613 :meth:`profile.Profile.runcall`, :meth:`cProfile.Profile.runcall`,
614 :meth:`bdb.Bdb.runcall`, :meth:`trace.Trace.runfunc` and
615 :func:`curses.wrapper`.
616 - *function* in :func:`unittest.addModuleCleanup` and
617 :meth:`unittest.TestCase.addCleanup`.
618 - *fn* in the :meth:`~concurrent.futures.Executor.submit` method of
619 :class:`concurrent.futures.ThreadPoolExecutor` and
620 :class:`concurrent.futures.ProcessPoolExecutor`.
621 - *callback* in :meth:`contextlib.ExitStack.callback`,
622 :meth:`contextlib.AsyncExitStack.callback` and
623 :meth:`contextlib.AsyncExitStack.push_async_callback`.
624 - *c* and *typeid* in the :meth:`~multiprocessing.managers.Server.create`
625 method of :class:`multiprocessing.managers.Server` and
626 :class:`multiprocessing.managers.SharedMemoryServer`.
627 - *obj* in :func:`weakref.finalize`.
628
629 In future releases of Python they will be :ref:`positional-only
630 <positional-only_parameter>`.
631 (Contributed by Serhiy Storchaka in :issue:`36492`.)
632
Serhiy Storchaka6a44f6e2019-02-25 17:57:58 +0200633
Victor Stinner73104fa2018-11-29 09:58:20 +0100634API and Feature Removals
635========================
636
637The following features and APIs have been removed from Python 3.8:
638
Victor Stinnerd7538dd2018-12-14 13:37:26 +0100639* The :mod:`macpath` module, deprecated in Python 3.7, has been removed.
640 (Contributed by Victor Stinner in :issue:`35471`.)
641
Victor Stinner73104fa2018-11-29 09:58:20 +0100642* The function :func:`platform.popen` has been removed, it was deprecated since
643 Python 3.3: use :func:`os.popen` instead.
Ned Deily07a18922018-01-31 18:12:38 -0500644
Brett Cannona8c34242018-04-20 14:15:40 -0700645* The ``pyvenv`` script has been removed in favor of ``python3.8 -m venv``
646 to help eliminate confusion as to what Python interpreter the ``pyvenv``
647 script is tied to. (Contributed by Brett Cannon in :issue:`25427`.)
Ned Deily07a18922018-01-31 18:12:38 -0500648
INADA Naoki698865d2018-06-19 17:28:50 +0900649* ``parse_qs``, ``parse_qsl``, and ``escape`` are removed from :mod:`cgi`
650 module. They are deprecated from Python 3.2 or older.
651
INADA Naoki461a1c42018-06-28 17:10:36 +0900652* ``filemode`` function is removed from :mod:`tarfile` module.
653 It is not documented and deprecated since Python 3.3.
INADA Naoki698865d2018-06-19 17:28:50 +0900654
Serhiy Storchaka02ec92f2018-07-24 12:03:34 +0300655* The :class:`~xml.etree.ElementTree.XMLParser` constructor no longer accepts
656 the *html* argument. It never had effect and was deprecated in Python 3.4.
657 All other parameters are now :ref:`keyword-only <keyword-only_parameter>`.
658 (Contributed by Serhiy Storchaka in :issue:`29209`.)
659
660* Removed the ``doctype()`` method of :class:`~xml.etree.ElementTree.XMLParser`.
661 (Contributed by Serhiy Storchaka in :issue:`29209`.)
662
Inada Naoki6a16b182019-03-18 15:44:11 +0900663* "unicode_internal" codec is removed.
664 (Contributed by Inada Naoki in :issue:`36297`.)
665
Ned Deily07a18922018-01-31 18:12:38 -0500666
667Porting to Python 3.8
668=====================
669
670This section lists previously described changes and other bugfixes
671that may require changes to your code.
672
673
Serhiy Storchaka07ca9af2018-02-04 10:53:48 +0200674Changes in Python behavior
675--------------------------
676
677* Yield expressions (both ``yield`` and ``yield from`` clauses) are now disallowed
678 in comprehensions and generator expressions (aside from the iterable expression
Serhiy Storchaka2b57c432018-12-19 08:09:46 +0200679 in the leftmost :keyword:`!for` clause).
Serhiy Storchaka07ca9af2018-02-04 10:53:48 +0200680 (Contributed by Serhiy Storchaka in :issue:`10544`.)
681
Serhiy Storchaka3bcbedc2019-01-18 07:47:48 +0200682* The compiler now produces a :exc:`SyntaxWarning` when identity checks
683 (``is`` and ``is not``) are used with certain types of literals
684 (e.g. strings, ints). These can often work by accident in CPython,
685 but are not guaranteed by the language spec. The warning advises users
686 to use equality tests (``==`` and ``!=``) instead.
687 (Contributed by Serhiy Storchaka in :issue:`34850`.)
688
Serhiy Storchaka7a0630c2019-04-08 14:34:04 +0300689* The CPython interpreter can swallow exceptions in some circumstances.
690 In Python 3.8 this happens in less cases. In particular, exceptions
691 raised when getting the attribute from the type dictionary are no longer
692 ignored. (Contributed by Serhiy Storchaka in :issue:`35459`.)
693
Serhiy Storchaka07ca9af2018-02-04 10:53:48 +0200694
Serhiy Storchaka97f1ca12018-02-01 18:49:21 +0200695Changes in the Python API
696-------------------------
697
Victor Stinner73104fa2018-11-29 09:58:20 +0100698* The function :func:`platform.popen` has been removed, it was deprecated since
699 Python 3.3: use :func:`os.popen` instead.
700
Raymond Hettingerfc06a192019-03-12 00:43:27 -0700701* The :func:`statistics.mode` function no longer raises an exception
702 when given multimodal data. Instead, it returns the first mode
703 encountered in the input data. (Contributed by Raymond Hettinger
704 in :issue:`35892`.)
705
Serhiy Storchaka97f1ca12018-02-01 18:49:21 +0200706* The :meth:`~tkinter.ttk.Treeview.selection` method of the
707 :class:`tkinter.ttk.Treeview` class no longer takes arguments. Using it with
708 arguments for changing the selection was deprecated in Python 3.6. Use
709 specialized methods like :meth:`~tkinter.ttk.Treeview.selection_set` for
710 changing the selection. (Contributed by Serhiy Storchaka in :issue:`31508`.)
Serhiy Storchaka6c85efa52018-02-05 22:47:31 +0200711
Diego Rojas06e1e682019-03-16 18:44:56 -0500712* The :meth:`writexml`, :meth:`toxml` and :meth:`toprettyxml` methods of the
713 :mod:`xml.dom.minidom` module, and :mod:`xml.etree` now preserve the attribute
714 order specified by the user.
715 (Contributed by Diego Rojas and Raymond Hettinger in :issue:`34160`.)
716
Serhiy Storchaka6c85efa52018-02-05 22:47:31 +0200717* A :mod:`dbm.dumb` database opened with flags ``'r'`` is now read-only.
718 :func:`dbm.dumb.open` with flags ``'r'`` and ``'w'`` no longer creates
719 a database if it does not exist.
720 (Contributed by Serhiy Storchaka in :issue:`32749`.)
Serhiy Storchaka520b7ae2018-02-22 23:33:30 +0200721
Serhiy Storchaka02ec92f2018-07-24 12:03:34 +0300722* The ``doctype()`` method defined in a subclass of
723 :class:`~xml.etree.ElementTree.XMLParser` will no longer be called and will
724 cause emitting a :exc:`RuntimeWarning` instead of a :exc:`DeprecationWarning`.
725 Define the :meth:`doctype() <xml.etree.ElementTree.TreeBuilder.doctype>`
726 method on a target for handling an XML doctype declaration.
727 (Contributed by Serhiy Storchaka in :issue:`29209`.)
728
Serhiy Storchakaf5e7b192018-05-20 08:48:12 +0300729* A :exc:`RuntimeError` is now raised when the custom metaclass doesn't
730 provide the ``__classcell__`` entry in the namespace passed to
731 ``type.__new__``. A :exc:`DeprecationWarning` was emitted in Python
732 3.6--3.7. (Contributed by Serhiy Storchaka in :issue:`23722`.)
733
Scott Sandersoncebe80b2018-06-07 05:46:42 -0400734* The :class:`cProfile.Profile` class can now be used as a context
735 manager. (Contributed by Scott Sanderson in :issue:`29235`.)
Serhiy Storchaka520b7ae2018-02-22 23:33:30 +0200736
Giampaolo Rodolac7f02a92018-06-19 08:27:29 -0700737* :func:`shutil.copyfile`, :func:`shutil.copy`, :func:`shutil.copy2`,
738 :func:`shutil.copytree` and :func:`shutil.move` use platform-specific
739 "fast-copy" syscalls (see
740 :ref:`shutil-platform-dependent-efficient-copy-operations` section).
741
742* :func:`shutil.copyfile` default buffer size on Windows was changed from
743 16 KiB to 1 MiB.
744
INADA Naokid5c875b2018-07-11 17:42:49 +0900745* ``PyGC_Head`` struct is changed completely. All code touched the
746 struct member should be rewritten. (See :issue:`33597`)
747
Eric Snowbe3b2952019-02-23 11:35:52 -0700748* The ``PyInterpreterState`` struct has been moved into the "internal"
749 header files (specifically Include/internal/pycore_pystate.h). An
750 opaque ``PyInterpreterState`` is still available as part of the public
751 API (and stable ABI). The docs indicate that none of the struct's
752 fields are public, so we hope no one has been using them. However,
753 if you do rely on one or more of those private fields and have no
754 alternative then please open a BPO issue. We'll work on helping
755 you adjust (possibly including adding accessor functions to the
756 public API). (See :issue:`35886`.)
757
Alex Grönholmcca4eec2018-08-09 00:06:47 +0300758* Asyncio tasks can now be named, either by passing the ``name`` keyword
759 argument to :func:`asyncio.create_task` or
Yury Selivanov7c7605f2018-09-11 09:54:40 -0700760 the :meth:`~asyncio.loop.create_task` event loop method, or by
Alex Grönholmcca4eec2018-08-09 00:06:47 +0300761 calling the :meth:`~asyncio.Task.set_name` method on the task object. The
762 task name is visible in the ``repr()`` output of :class:`asyncio.Task` and
763 can also be retrieved using the :meth:`~asyncio.Task.get_name` method.
764
Berker Peksage7d4b2f2018-08-22 21:21:05 +0300765* The :meth:`mmap.flush() <mmap.mmap.flush>` method now returns ``None`` on
766 success and raises an exception on error under all platforms. Previously,
767 its behavior was platform-depended: a nonzero value was returned on success;
768 zero was returned on error under Windows. A zero value was returned on
769 success; an exception was raised on error under Unix.
770 (Contributed by Berker Peksag in :issue:`2122`.)
771
Pablo Galindofa221d82018-09-08 00:16:17 +0100772* The function :func:`math.factorial` no longer accepts arguments that are not
773 int-like. (Contributed by Pablo Galindo in :issue:`33083`.)
774
Andrés Delfinoca682612018-11-07 14:29:14 -0300775* :mod:`xml.dom.minidom` and :mod:`xml.sax` modules no longer process
Christian Heimes17b1d5d2018-09-23 09:50:25 +0200776 external entities by default.
777 (Contributed by Christian Heimes in :issue:`17239`.)
INADA Naokid5c875b2018-07-11 17:42:49 +0900778
Xiang Zhang4fb0b8b2018-12-12 20:46:55 +0800779* Deleting a key from a read-only :mod:`dbm` database (:mod:`dbm.dumb`,
780 :mod:`dbm.gnu` or :mod:`dbm.ndbm`) raises :attr:`error` (:exc:`dbm.dumb.error`,
781 :exc:`dbm.gnu.error` or :exc:`dbm.ndbm.error`) instead of :exc:`KeyError`.
782 (Contributed by Xiang Zhang in :issue:`33106`.)
783
Steve Dower8ef864d2019-03-12 15:15:26 -0700784* :func:`~os.path.expanduser` on Windows now prefers the :envvar:`USERPROFILE`
785 environment variable and does not use :envvar:`HOME`, which is not normally
786 set for regular user accounts.
787
Steve Dower2438cdf2019-03-29 16:37:16 -0700788.. _bpo-36085-whatsnew:
789
790* DLL dependencies for extension modules and DLLs loaded with :mod:`ctypes` on
791 Windows are now resolved more securely. Only the system paths, the directory
792 containing the DLL or PYD file, and directories added with
793 :func:`~os.add_dll_directory` are searched for load-time dependencies.
794 Specifically, :envvar:`PATH` and the current working directory are no longer
795 used, and modifications to these will no longer have any effect on normal DLL
796 resolution. If your application relies on these mechanisms, you should check
797 for :func:`~os.add_dll_directory` and if it exists, use it to add your DLLs
Steve Dower79da3882019-03-30 20:58:17 -0700798 directory while loading your library. Note that Windows 7 users will need to
799 ensure that Windows Update KB2533625 has been installed (this is also verified
800 by the installer).
Steve Dower2438cdf2019-03-29 16:37:16 -0700801 (See :issue:`36085`.)
802
Xiang Zhang4fb0b8b2018-12-12 20:46:55 +0800803
Inada Naokid3c72a22019-03-23 21:04:40 +0900804Changes in the C API
805--------------------
806
807* Use of ``#`` variants of formats in parsing or building value (e.g.
808 :c:func:`PyArg_ParseTuple`, :c:func:`Py_BuildValue`, :c:func:`PyObject_CallFunction`,
809 etc.) without ``PY_SSIZE_T_CLEAN`` defined raises ``DeprecationWarning`` now.
810 It will be removed in 3.10 or 4.0. Read :ref:`arg-parsing` for detail.
811 (Contributed by Inada Naoki in :issue:`36381`.)
812
813
Eddie Elizondo364f0b02019-03-27 07:52:18 -0400814Changes in the C API
815--------------------------
816
817* Instances of heap-allocated types (such as those created with
818 :c:func:`PyType_FromSpec`) hold a reference to their type object.
819 Increasing the reference count of these type objects has been moved from
820 :c:func:`PyType_GenericAlloc` to the more low-level functions,
821 :c:func:`PyObject_Init` and :c:func:`PyObject_INIT`.
822 This makes types created through :c:func:`PyType_FromSpec` behave like
823 other classes in managed code.
824
825 Statically allocated types are not affected.
826
827 For the vast majority of cases, there should be no side effect.
828 However, types that manually increase the reference count after allocating
829 an instance (perhaps to work around the bug) may now become immortal.
830 To avoid this, these classes need to call Py_DECREF on the type object
831 during instance deallocation.
832
833 To correctly port these types into 3.8, please apply the following
834 changes:
835
836 * Remove :c:macro:`Py_INCREF` on the type object after allocating an
837 instance - if any.
838 This may happen after calling :c:func:`PyObject_New`,
839 :c:func:`PyObject_NewVar`, :c:func:`PyObject_GC_New`,
840 :c:func:`PyObject_GC_NewVar`, or any other custom allocator that uses
841 :c:func:`PyObject_Init` or :c:func:`PyObject_INIT`.
842
843 Example::
844
845 static foo_struct *
846 foo_new(PyObject *type) {
847 foo_struct *foo = PyObject_GC_New(foo_struct, (PyTypeObject *) type);
848 if (foo == NULL)
849 return NULL;
850 #if PY_VERSION_HEX < 0x03080000
851 // Workaround for Python issue 35810; no longer necessary in Python 3.8
852 PY_INCREF(type)
853 #endif
854 return foo;
855 }
856
857 * Ensure that all custom ``tp_dealloc`` functions of heap-allocated types
858 decrease the type's reference count.
859
860 Example::
861
862 static void
863 foo_dealloc(foo_struct *instance) {
864 PyObject *type = Py_TYPE(instance);
865 PyObject_GC_Del(instance);
866 #if PY_VERSION_HEX >= 0x03080000
867 // This was not needed before Python 3.8 (Python issue 35810)
868 Py_DECREF(type);
869 #endif
870 }
871
872 (Contributed by Eddie Elizondo in :issue:`35810`.)
873
874
Serhiy Storchaka520b7ae2018-02-22 23:33:30 +0200875CPython bytecode changes
876------------------------
877
878* The interpreter loop has been simplified by moving the logic of unrolling
879 the stack of blocks into the compiler. The compiler emits now explicit
Serhiy Storchaka3f819ca2018-10-31 02:26:06 +0200880 instructions for adjusting the stack of values and calling the
881 cleaning-up code for :keyword:`break`, :keyword:`continue` and
882 :keyword:`return`.
Serhiy Storchaka520b7ae2018-02-22 23:33:30 +0200883
884 Removed opcodes :opcode:`BREAK_LOOP`, :opcode:`CONTINUE_LOOP`,
885 :opcode:`SETUP_LOOP` and :opcode:`SETUP_EXCEPT`. Added new opcodes
886 :opcode:`ROT_FOUR`, :opcode:`BEGIN_FINALLY`, :opcode:`CALL_FINALLY` and
887 :opcode:`POP_FINALLY`. Changed the behavior of :opcode:`END_FINALLY`
888 and :opcode:`WITH_CLEANUP_START`.
889
890 (Contributed by Mark Shannon, Antoine Pitrou and Serhiy Storchaka in
891 :issue:`17611`.)
Serhiy Storchaka702f8f32018-03-23 14:34:35 +0200892
893* Added new opcode :opcode:`END_ASYNC_FOR` for handling exceptions raised
894 when awaiting a next item in an :keyword:`async for` loop.
895 (Contributed by Serhiy Storchaka in :issue:`33041`.)
Raymond Hettingerf75d59e2019-02-02 22:54:56 -0800896
897
898Demos and Tools
899---------------
900
901* Added a benchmark script for timing various ways to access variables:
902 ``Tools/scripts/var_access_benchmark.py``.
903 (Contributed by Raymond Hettinger in :issue:`35884`.)