42
42
module.
43
43
(Contributed by P.Y. Developer in :issue:`12345`.)
44
44
45
- This saves the maintainer the effort of going through the Mercurial log
45
+ This saves the maintainer the effort of going through the git log
46
46
when researching a change.
47
47
48
48
This article explains the new features in Python 3.10, compared to 3.9.
@@ -143,7 +143,7 @@ For instance, consider the following code (notice the unclosed '{'):
143
143
38 : 4 , 39 : 4 , 45 : 5 , 46 : 5 , 47 : 5 , 48 : 5 , 49 : 5 , 54 : 6 ,
144
144
some_other_code = foo()
145
145
146
- previous versions of the interpreter reported confusing places as the location of
146
+ Previous versions of the interpreter reported confusing places as the location of
147
147
the syntax error:
148
148
149
149
.. code- block:: python
@@ -153,7 +153,7 @@ the syntax error:
153
153
^
154
154
SyntaxError : invalid syntax
155
155
156
- but in Python3 .10 a more informative error is emitted:
156
+ but in Python 3 .10 a more informative error is emitted:
157
157
158
158
.. code- block:: python
159
159
@@ -171,7 +171,7 @@ These improvements are inspired by previous work in the PyPy interpreter.
171
171
(Contributed by Pablo Galindo in :issue:`42864 ` and Batuhan Taskaya in
172
172
:issue:`40176 ` .)
173
173
174
- :exc:`SyntaxError ` exceptions raised by the intepreter will now highlight the
174
+ :exc:`SyntaxError ` exceptions raised by the interpreter will now highlight the
175
175
full error range of the expression that consistutes the syntax error itself,
176
176
instead of just where the problem is detected. In this way, instead of displaying
177
177
(before Python 3.10 ):
@@ -194,7 +194,7 @@ now Python 3.10 will display the exception as:
194
194
^^^^^^^^^^^^^^^^^^^^
195
195
SyntaxError : Generator expression must be parenthesized
196
196
197
- This improvement has been contributed by Pablo Galindo in :issue:`43914 ` .
197
+ This improvement was contributed by Pablo Galindo in :issue:`43914 ` .
198
198
199
199
A considerable amount of new specialized messages for :exc:`SyntaxError ` exceptions
200
200
have been incorporated. Some of the most notable ones:
@@ -408,7 +408,7 @@ in C, Java or JavaScript (and many other languages). Often the switch statement
408
408
is used for comparison of an object / expression with case statements containing
409
409
literals.
410
410
411
- More powerful examples of pattern matching can be found in languages, such as
411
+ More powerful examples of pattern matching can be found in languages such as
412
412
Scala and Elixir. With structural pattern matching, the approach is " declarative" and
413
413
explicitly states the conditions (the patterns) for data to match.
414
414
@@ -649,7 +649,7 @@ platforms, omitting ``encoding`` option when opening UTF-8 files
649
649
with open (" data.json" ) as f:
650
650
data = json.load(f)
651
651
652
- To find this type of bug, optional `` EncodingWarning`` is added.
652
+ To find this type of bug, an optional `` EncodingWarning`` is added.
653
653
It is emitted when :data:`sys.flags.warn_default_encoding < sys.flags> `
654
654
is true and locale- specific default encoding is used.
655
655
@@ -824,7 +824,7 @@ Improved Modules
824
824
asyncio
825
825
------ -
826
826
827
- Added missing :meth:`~ asyncio.events.AbstractEventLoop.connect_accepted_socket`
827
+ Add missing :meth:`~ asyncio.events.AbstractEventLoop.connect_accepted_socket`
828
828
method.
829
829
(Contributed by Alex Grönholm in :issue:`41332 ` .)
830
830
@@ -904,7 +904,7 @@ they are provided by the underlying curses library.
904
904
dataclasses
905
905
---------- -
906
906
907
- Added `` slots`` parameter in :func:`dataclasses.dataclass` decorator.
907
+ Add `` slots`` parameter in :func:`dataclasses.dataclass` decorator.
908
908
(Contributed by Yurii Karabas in :issue:`42269 ` )
909
909
910
910
.. _distutils- deprecated:
@@ -953,7 +953,7 @@ Add :class:`enum.StrEnum` for enums where all members are strings.
953
953
fileinput
954
954
-------- -
955
955
956
- Added * encoding* and * errors* parameters in :func:`fileinput.input` and
956
+ Add * encoding* and * errors* parameters in :func:`fileinput.input` and
957
957
:class :`fileinput.FileInput` .
958
958
(Contributed by Inada Naoki in :issue:`43712 ` .)
959
959
@@ -964,13 +964,13 @@ when *mode* is "r" and file is compressed, like uncompressed files.
964
964
gc
965
965
--
966
966
967
- Added audit hooks for :func:`gc.get_objects` , :func:`gc.get_referrers` and
967
+ Add audit hooks for :func:`gc.get_objects` , :func:`gc.get_referrers` and
968
968
:func:`gc.get_referents` . (Contributed by Pablo Galindo in :issue:`43439 ` .)
969
969
970
970
glob
971
971
----
972
972
973
- Added the * root_dir* and * dir_fd* parameters in :func:`~ glob.glob` and
973
+ Add the * root_dir* and * dir_fd* parameters in :func:`~ glob.glob` and
974
974
:func:`~ glob.iglob` which allow to specify the root directory for searching.
975
975
(Contributed by Serhiy Storchaka in :issue:`38144 ` .)
976
976
@@ -1039,7 +1039,7 @@ inspect
1039
1039
When a module does not define `` __loader__`` , fall back to `` __spec__ .loader`` .
1040
1040
(Contributed by Brett Cannon in :issue:`42133 ` .)
1041
1041
1042
- Added :func:`inspect.get_annotations` , which safely computes the annotations
1042
+ Add :func:`inspect.get_annotations` , which safely computes the annotations
1043
1043
defined on an object . It works around the quirks of accessing the annotations
1044
1044
on various types of objects, and makes very few assumptions about the object
1045
1045
it examines. :func:`inspect.get_annotations` can also correctly un- stringize
@@ -1048,7 +1048,7 @@ best practice for accessing the annotations dict defined on any Python object;
1048
1048
for more information on best practices for working with annotations, please see
1049
1049
:ref:`annotations- howto` .
1050
1050
Relatedly, :func:`inspect.signature` ,
1051
- :func:`inspect.Signature.from_callable` , and `` inspect.Signature.from_function` `
1051
+ :func:`inspect.Signature.from_callable` , and :func: ` inspect.Signature.from_function`
1052
1052
now call :func:`inspect.get_annotations` to retrieve annotations. This means
1053
1053
:func:`inspect.signature` and :func:`inspect.Signature.from_callable` can
1054
1054
also now un- stringize stringized annotations.
@@ -1063,41 +1063,41 @@ When a module does not define ``__loader__``, fall back to ``__spec__.loader``.
1063
1063
os
1064
1064
--
1065
1065
1066
- Added :func:`os.cpu_count()` support for VxWorks RTOS .
1066
+ Add :func:`os.cpu_count()` support for VxWorks RTOS .
1067
1067
(Contributed by Peixing Xin in :issue:`41440 ` .)
1068
1068
1069
- Added a new function :func:`os.eventfd` and related helpers to wrap the
1069
+ Add a new function :func:`os.eventfd` and related helpers to wrap the
1070
1070
`` eventfd2`` syscall on Linux.
1071
1071
(Contributed by Christian Heimes in :issue:`41001 ` .)
1072
1072
1073
- Added :func:`os.splice()` that allows to move data between two file
1073
+ Add :func:`os.splice()` that allows to move data between two file
1074
1074
descriptors without copying between kernel address space and user
1075
1075
address space, where one of the file descriptors must refer to a
1076
1076
pipe. (Contributed by Pablo Galindo in :issue:`41625 ` .)
1077
1077
1078
- Added :data:`~ os.O_EVTONLY ` , :data:`~ os.O_FSYNC ` , :data:`~ os.O_SYMLINK `
1078
+ Add :data:`~ os.O_EVTONLY ` , :data:`~ os.O_FSYNC ` , :data:`~ os.O_SYMLINK `
1079
1079
and :data:`~ os.O_NOFOLLOW_ANY ` for macOS.
1080
1080
(Contributed by Dong- hee Na in :issue:`43106 ` .)
1081
1081
1082
1082
pathlib
1083
1083
------ -
1084
1084
1085
- Added slice support to :attr:`PurePath.parents < pathlib.PurePath.parents> ` .
1085
+ Add slice support to :attr:`PurePath.parents < pathlib.PurePath.parents> ` .
1086
1086
(Contributed by Joshua Cannon in :issue:`35498 ` )
1087
1087
1088
- Added negative indexing support to :attr:`PurePath.parents
1088
+ Add negative indexing support to :attr:`PurePath.parents
1089
1089
< pathlib.PurePath.parents> `.
1090
1090
(Contributed by Yaroslav Pankovych in :issue:`21041 ` )
1091
1091
1092
- Added :meth:`Path.hardlink_to < pathlib.Path.hardlink_to> ` method that
1092
+ Add :meth:`Path.hardlink_to < pathlib.Path.hardlink_to> ` method that
1093
1093
supersedes :meth:`~ pathlib.Path.link_to` . The new method has the same argument
1094
1094
order as :meth:`~ pathlib.Path.symlink_to` .
1095
1095
(Contributed by Barney Gale in :issue:`39950 ` .)
1096
1096
1097
1097
platform
1098
1098
--------
1099
1099
1100
- Added :func:`platform.freedesktop_os_release()` to retrieve operation system
1100
+ Add :func:`platform.freedesktop_os_release()` to retrieve operation system
1101
1101
identification from `freedesktop.org os- release
1102
1102
< https:// www.freedesktop.org/ software/ systemd/ man/ os- release.html> `_ standard file .
1103
1103
(Contributed by Christian Heimes in :issue:`28468 ` )
@@ -1111,13 +1111,13 @@ pprint
1111
1111
py_compile
1112
1112
----------
1113
1113
1114
- Added `` -- quiet`` option to command- line interface of :mod:`py_compile` .
1114
+ Add `` -- quiet`` option to command- line interface of :mod:`py_compile` .
1115
1115
(Contributed by Gregory Schevchenko in :issue:`38731 ` .)
1116
1116
1117
1117
pyclbr
1118
1118
------
1119
1119
1120
- Added an `` end_lineno`` attribute to the `` Function`` and `` Class``
1120
+ Add an `` end_lineno`` attribute to the `` Function`` and `` Class``
1121
1121
objects in the tree returned by :func:`pyclbr.readline` and
1122
1122
:func:`pyclbr.readline_ex` . It matches the existing (start) `` lineno`` .
1123
1123
(Contributed by Aviral Srivastava in :issue:`38307 ` .)
@@ -1132,7 +1132,7 @@ instead of :mod:`pickle` protocol ``3`` when creating shelves.
1132
1132
statistics
1133
1133
----------
1134
1134
1135
- Added :func:`~ statistics.covariance` , Pearson' s
1135
+ Add :func:`~ statistics.covariance` , Pearson' s
1136
1136
:func:`~ statistics.correlation` , and simple
1137
1137
:func:`~ statistics.linear_regression` functions.
1138
1138
(Contributed by Tymoteusz Wołodźko in :issue:`38490 ` .)
@@ -1149,7 +1149,7 @@ socket
1149
1149
The exception :exc:`socket.timeout` is now an alias of :exc:`TimeoutError ` .
1150
1150
(Contributed by Christian Heimes in :issue:`42413 ` .)
1151
1151
1152
- Added option to create MPTCP sockets with `` IPPROTO_MPTCP ``
1152
+ Add option to create MPTCP sockets with `` IPPROTO_MPTCP ``
1153
1153
(Contributed by Rui Cunha in :issue:`43571 ` .)
1154
1154
1155
1155
ssl
@@ -1229,7 +1229,7 @@ simulate (the default is still :data:`signal.SIGINT`).
1229
1229
threading
1230
1230
-------- -
1231
1231
1232
- Added :func:`threading.gettrace` and :func:`threading.getprofile` to
1232
+ Add :func:`threading.gettrace` and :func:`threading.getprofile` to
1233
1233
retrieve the functions set by :func:`threading.settrace` and
1234
1234
:func:`threading.setprofile` respectively.
1235
1235
(Contributed by Mario Corchero in :issue:`42251 ` .)
@@ -1251,7 +1251,7 @@ as a positional-only argument.
1251
1251
types
1252
1252
---- -
1253
1253
1254
- Reintroduced the :data:`types.EllipsisType` , :data:`types.NoneType`
1254
+ Reintroduce the :data:`types.EllipsisType` , :data:`types.NoneType`
1255
1255
and :data:`types.NotImplementedType` classes, providing a new set
1256
1256
of types readily interpretable by type checkers.
1257
1257
(Contributed by Bas van Beek in :issue:`41810 ` .)
@@ -1355,12 +1355,12 @@ Optimizations
1355
1355
1356
1356
* Use a new output buffer management code for :mod:`bz2` / :mod:`lzma` /
1357
1357
:mod:`zlib` modules, and add `` .readall()`` function to
1358
- `` _compression.DecompressReader`` class . bz2 decompression 1. 09x ~ 1. 17x
1358
+ `` _compression.DecompressReader`` class . bz2 decompression is now 1. 09x ~ 1. 17x
1359
1359
faster, lzma decompression 1. 20x ~ 1. 32x faster, `` GzipFile.read(- 1 )`` 1. 11x
1360
1360
~ 1. 18x faster. (Contributed by Ma Lin, reviewed by Gregory P. Smith, in :issue:`41486 ` )
1361
1361
1362
1362
* When using stringized annotations, annotations dicts for functions are no longer
1363
- created when the function is created. Instead, they' re stored as a tuple of
1363
+ created when the function is created. Instead, they are stored as a tuple of
1364
1364
strings, and the function object lazily converts this into the annotations dict
1365
1365
on demand. This optimization cuts the CPU time needed to define an annotated
1366
1366
function by half.
@@ -1371,13 +1371,13 @@ Optimizations
1371
1371
algorithm to avoid quadratic behavior on long strings. (Contributed
1372
1372
by Dennis Sweeney in :issue:`41972 ` )
1373
1373
1374
- * Added micro- optimizations to `` _PyType_Lookup()`` to improve type attribute cache lookup
1374
+ * Add micro- optimizations to `` _PyType_Lookup()`` to improve type attribute cache lookup
1375
1375
performance in the common case of cache hits. This makes the interpreter 1.04 times faster
1376
- in average (Contributed by Dino Viehland in :issue:`43452 ` )
1376
+ on average. (Contributed by Dino Viehland in :issue:`43452 ` )
1377
1377
1378
- * Following built- in functions now support the faster :pep:`590 ` vectorcall calling convention:
1378
+ * The following built- in functions now support the faster :pep:`590 ` vectorcall calling convention:
1379
1379
:func:`map ` , :func:`filter ` , :func:`reversed ` , :func:`bool ` and :func:`float ` .
1380
- (Contributed by Dong- hee Na and Jeroen Demeyerin in :issue:`43575 ` , :issue:`43287 ` , :issue:`41922 ` , :issue:`41873 ` and :issue:`41870 ` )
1380
+ (Contributed by Dong- hee Na and Jeroen Demeyer in :issue:`43575 ` , :issue:`43287 ` , :issue:`41922 ` , :issue:`41873 ` and :issue:`41870 ` )
1381
1381
1382
1382
* :class :`BZ2File` performance is improved by removing internal `` RLock`` .
1383
1383
This makes :class :`BZ2File` thread unsafe in the face of multiple simultaneous
@@ -1492,11 +1492,11 @@ Deprecated
1492
1492
scheduled for removal in Python 3.12 .
1493
1493
(Contributed by Erlend E. Aasland in :issue:`42264 ` .)
1494
1494
1495
- * :func:`asyncio.get_event_loop` emits now a deprecation warning if there is
1496
- no running event loop. In future it will be an alias of
1495
+ * :func:`asyncio.get_event_loop` now emits a deprecation warning if there is
1496
+ no running event loop. In the future it will be an alias of
1497
1497
:func:`~ asyncio.get_running_loop` .
1498
1498
:mod:`asyncio` functions which implicitly create a :class :`~ asyncio.Future`
1499
- or :class :`~ asyncio.Task` objects emit now
1499
+ or :class :`~ asyncio.Task` objects now emit
1500
1500
a deprecation warning if there is no running event loop and no explicit
1501
1501
* loop* argument is passed: :func:`~ asyncio.ensure_future` ,
1502
1502
:func:`~ asyncio.wrap_future` , :func:`~ asyncio.gather` ,
@@ -1509,7 +1509,7 @@ Deprecated
1509
1509
deprecated, scheduled for removal in Python 3.12 . Its use is strongly
1510
1510
discouraged by the SQLite3 documentation. See `the SQLite3 docs
1511
1511
< https:// sqlite.org/ c3ref/ enable_shared_cache.html> `_ for more details.
1512
- If shared cache must be used, open the database in URI mode using the
1512
+ If a shared cache must be used, open the database in URI mode using the
1513
1513
`` cache=shared`` query parameter.
1514
1514
(Contributed by Erlend E. Aasland in :issue:`24464 ` .)
1515
1515
@@ -1553,7 +1553,7 @@ Removed
1553
1553
1554
1554
* The `` ParserBase.error()`` method from the private and undocumented `` _markupbase``
1555
1555
module has been removed. :class :`html.parser.HTMLParser` is the only subclass of
1556
- `` ParserBase`` and its `` error()`` implementation has already been removed in
1556
+ `` ParserBase`` and its `` error()`` implementation was already removed in
1557
1557
Python 3.5 .
1558
1558
(Contributed by Berker Peksag in :issue:`31844 ` .)
1559
1559
@@ -1646,7 +1646,7 @@ Changes in the Python API
1646
1646
:doc:`high- level API < ../ library/ asyncio- api- index> ` following deprecation
1647
1647
in Python 3.8 .
1648
1648
1649
- A coroutine that currently look like this::
1649
+ A coroutine that currently looks like this::
1650
1650
1651
1651
async def foo(loop):
1652
1652
await asyncio.sleep(1 , loop = loop)
@@ -1695,7 +1695,7 @@ Build Changes
1695
1695
* The :mod:`atexit` module must now always be built as a built- in module.
1696
1696
(Contributed by Victor Stinner in :issue:`42639 ` .)
1697
1697
1698
- * Added :option:`-- disable- test- modules` option to the `` configure`` script:
1698
+ * Add :option:`-- disable- test- modules` option to the `` configure`` script:
1699
1699
don' t build nor install test modules.
1700
1700
(Contributed by Xavier de Gaye, Thomas Petazzoni and Peixing Xin in :issue:`27640 ` .)
1701
1701
@@ -1759,15 +1759,15 @@ New Features
1759
1759
sending value into iterator without raising `` StopIteration `` exception.
1760
1760
(Contributed by Vladimir Matveev in :issue:`41756 ` .)
1761
1761
1762
- * Added :c:func:`PyUnicode_AsUTF8AndSize` to the limited C API .
1762
+ * Add :c:func:`PyUnicode_AsUTF8AndSize` to the limited C API .
1763
1763
(Contributed by Alex Gaynor in :issue:`41784 ` .)
1764
1764
1765
- * Added :c:func:`PyModule_AddObjectRef` function: similar to
1765
+ * Add :c:func:`PyModule_AddObjectRef` function: similar to
1766
1766
:c:func:`PyModule_AddObject` but don' t steal a reference to the value on
1767
1767
success.
1768
1768
(Contributed by Victor Stinner in :issue:`1635741 ` .)
1769
1769
1770
- * Added :c:func:`Py_NewRef` and :c:func:`Py_XNewRef` functions to increment the
1770
+ * Add :c:func:`Py_NewRef` and :c:func:`Py_XNewRef` functions to increment the
1771
1771
reference count of an object and return the object .
1772
1772
(Contributed by Victor Stinner in :issue:`42262 ` .)
1773
1773
@@ -1787,7 +1787,7 @@ New Features
1787
1787
object is an instance of :class :`set ` but not an instance of a subtype.
1788
1788
(Contributed by Pablo Galindo in :issue:`43277 ` .)
1789
1789
1790
- * Added :c:func:`PyErr_SetInterruptEx` which allows passing a signal number
1790
+ * Add :c:func:`PyErr_SetInterruptEx` which allows passing a signal number
1791
1791
to simulate.
1792
1792
(Contributed by Antoine Pitrou in :issue:`43356 ` .)
1793
1793
@@ -1812,7 +1812,7 @@ New Features
1812
1812
singleton or the `` False `` singleton.
1813
1813
(Contributed by Victor Stinner in :issue:`43753 ` .)
1814
1814
1815
- * Add new functions to quickly control the garbage collector from C code:
1815
+ * Add new functions to control the garbage collector from C code:
1816
1816
:c:func:`PyGC_Enable()` ,
1817
1817
:c:func:`PyGC_Disable()` ,
1818
1818
:c:func:`PyGC_IsEnabled()` .
0 commit comments