summaryrefslogtreecommitdiffstatshomepage
path: root/docs/differences/python_36.rst
blob: 3315b0594dafc17332a9886623b2e4c99e0e0c05 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
.. _python_36:

Python 3.6
==========

Python 3.6 beta 1 was released on 12 Sep 2016, and a summary of the new features can be found here:

.. table::
  :widths: 30 50 20

  +-----------------------------------------------------------------------------------------------------------+-----------------+
  | **New Syntax Features**                                                                                   | **Status**      |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | `PEP 498 <https://www.python.org/dev/peps/pep-0498/>`_ | Literal String Formatting                        | Complete        |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | `PEP 515 <https://www.python.org/dev/peps/pep-0515/>`_ | Underscores in Numeric Literals                  | Complete        |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | `PEP 525 <https://www.python.org/dev/peps/pep-0525/>`_ | Asynchronous Generators                          |                 |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | `PEP 526 <https://www.python.org/dev/peps/pep-0526/>`_ | Syntax for Variable Annotations (provisional)    | Complete        |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | `PEP 530 <https://www.python.org/dev/peps/pep-0530/>`_ | Asynchronous Comprehensions                      |                 |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | **New Built-in Features**                                                                                                   |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | `PEP 468 <https://www.python.org/dev/peps/pep-0468/>`_ | Preserving the order of *kwargs* in a function   |                 |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | `PEP 487 <https://www.python.org/dev/peps/pep-0487/>`_ | Simpler customization of class creation          |                 |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | `PEP 520 <https://www.python.org/dev/peps/pep-0520/>`_ | Preserving Class Attribute Definition Order      |                 |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | **Standard Library Changes**                                                                                                |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | `PEP 495 <https://www.python.org/dev/peps/pep-0495/>`_ | Local Time Disambiguation                        |                 |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | `PEP 506 <https://www.python.org/dev/peps/pep-0506/>`_ | Adding A Secrets Module To The Standard Library  |                 |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | `PEP 519 <https://www.python.org/dev/peps/pep-0519/>`_ | Adding a file system path protocol               |                 |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | **CPython Internals**                                                                                                       |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | `PEP 509 <https://www.python.org/dev/peps/pep-0509/>`_ | Add a private version to dict                    | Won't do        |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | `PEP 523 <https://www.python.org/dev/peps/pep-0523/>`_ | Adding a frame evaluation API to CPython         |                 |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | **Linux/Window Changes**                                                                                                    |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | `PEP 524 <https://www.python.org/dev/peps/pep-0524/>`_ | Make ``os.urandom()`` blocking on Linux          |                 |
  |                                                        | (during system startup)                          |                 |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | `PEP 528 <https://www.python.org/dev/peps/pep-0528/>`_ | Change Windows console encoding to UTF-8         |                 |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+
  | `PEP 529 <https://www.python.org/dev/peps/pep-0529/>`_ | Change Windows filesystem encoding to UTF-8      |                 |
  +--------------------------------------------------------+--------------------------------------------------+-----------------+

Other Language Changes:

.. table::
  :widths: 90 10

  +-------------------------------------------------------------------------------------------------------------+---------------+
  | A *global* or *nonlocal* statement must now textually appear before the first use of the affected name in   |               |
  | the same scope. Previously this was a SyntaxWarning.                                                        |               |
  +-------------------------------------------------------------------------------------------------------------+---------------+
  | It is now possible to set a special method to None to indicate that the corresponding operation is not      |               |
  | available. For example, if a class sets *__iter__()* to *None* , the class is not iterable.                 |               |
  +-------------------------------------------------------------------------------------------------------------+---------------+
  | Long sequences of repeated traceback lines are now abbreviated as *[Previous line repeated {count} more     |               |
  | times]*                                                                                                     |               |
  +-------------------------------------------------------------------------------------------------------------+---------------+
  | Import now raises the new exception *ModuleNotFoundError* when it cannot find a module. Code that currently |               |
  | checks for ImportError (in try-except) will still work.                                                     |               |
  +-------------------------------------------------------------------------------------------------------------+---------------+
  | Class methods relying on zero-argument *super()* will now work correctly when called from metaclass methods |               |
  | during class creation.                                                                                      |               |
  +-------------------------------------------------------------------------------------------------------------+---------------+

Changes to built-in modules:

.. table::
  :widths: 90 10

  +--------------------------------------------------------------------------------------------------------------+----------------+
  | `array <https://docs.python.org/3.6/whatsnew/3.6.html#array>`_                                               |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | Exhausted iterators of *array.array* will now stay exhausted even if the iterated array is extended.         |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | `binascii <https://docs.python.org/3.6/whatsnew/3.6.html#binascii>`_                                         |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | The b2a_base64() function now accepts an optional newline keyword argument to control whether the newline    | Complete       |
  | character is appended to the return value                                                                    |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | `cmath <https://docs.python.org/3.6/whatsnew/3.6.html#cmath>`_                                               |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | The new cmath.tau (τ) constant has been added                                                                |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | New constants: *cmath.inf* and *cmath.nan* to match *math.inf* and *math.nan* , and also *cmath.infj* and    |                |
  | *cmath.nanj* to match the format used by complex repr                                                        |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | `collections <https://docs.python.org/3.6/whatsnew/3.6.html#collections>`_                                                    |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | The new Collection abstract base class has been added to represent sized iterable container classes          |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | The new *Reversible* abstract base class represents iterable classes that also provide the *__reversed__()*  |                |
  | method.                                                                                                      |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | The new *AsyncGenerator* abstract base class represents asynchronous generators.                             |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | The *namedtuple()* function now accepts an optional keyword argument module, which, when specified, is used  |                |
  | for the *__module__* attribute of the returned named tuple class.                                            |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | The verbose and rename arguments for *namedtuple()* are now keyword-only.                                    |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | Recursive *collections.deque* instances can now be pickled.                                                  |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | `hashlib <https://docs.python.org/3.6/whatsnew/3.6.html#hashlib>`_                                                            |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | BLAKE2 hash functions were added to the module. *blake2b()* and *blake2s()* are always available and support |                |
  | the full feature set of BLAKE2.                                                                              |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | The SHA-3 hash functions *sha3_224()*, *sha3_256()*, *sha3_384()*, *sha3_512()*, and *SHAKE* hash functions  |                |
  | *shake_128()* and *shake_256()* were added.                                                                  |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | The password-based key derivation function *scrypt()* is now available with OpenSSL 1.1.0 and newer.         |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | `json <https://docs.python.org/3.6/whatsnew/3.6.html#json>`_                                                                  |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | *json.load()* and *json.loads()* now support binary input. Encoded JSON should be represented using either   |                |
  | UTF-8, UTF-16, or UTF-32.                                                                                    |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | `math <https://docs.python.org/3.6/whatsnew/3.6.html#math>`_                                                                  |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | The new math.tau (τ) constant has been added                                                                 | Complete       |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | `os <https://docs.python.org/3.6/whatsnew/3.6.html#os>`_                                                                      |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | A new *close()* method allows explicitly closing a *scandir()* iterator. The *scandir()* iterator now        |                |
  | supports the context manager protocol.                                                                       |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | On Linux, *os.urandom()* now blocks until the system urandom entropy pool is initialized to increase the     |                |
  | security.                                                                                                    |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | The Linux *getrandom()* syscall (get random bytes) is now exposed as the new *os.getrandom()* function.      |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | `re <https://docs.python.org/3.6/whatsnew/3.6.html#re>`_                                                                      |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | Added support of modifier spans in regular expressions. Examples: *'(?i:p)ython'* matches 'python' and       |                |
  | 'Python', but not 'PYTHON'; *'(?i)g(?-i:v)r'* matches *'GvR'* and *'gvr'*, but not *'GVR'*.                  |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | Match object groups can be accessed by *__getitem__*, which is equivalent to *group()*. So *mo['name']* is   |                |
  | now equivalent to *mo.group('name')*.                                                                        |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | Match objects now support index-like objects as group indices.                                               |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | `socket <https://docs.python.org/3.6/whatsnew/3.6.html#socket>`_                                                              |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | The *ioctl()* function now supports the *SIO_LOOPBACK_FAST_PATH* control code.                               |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | The *getsockopt()* constants *SO_DOMAIN* , *SO_PROTOCOL*, *SO_PEERSEC* , and *SO_PASSSEC* are now supported. |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | The *setsockopt()* now supports the *setsockopt(level, optname, None, optlen: int)* form.                    |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | The socket module now supports the address family *AF_ALG* to interface with Linux Kernel crypto API.        |                |
  | *ALG_*, *SOL_ALG* and *sendmsg_afalg()* were added.                                                          |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | New Linux constants *TCP_USER_TIMEOUT* and *TCP_CONGESTION* were added.                                      |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | `ssl <https://docs.python.org/3.6/whatsnew/3.6.html#ssl>`_                                                                    |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | ssl supports OpenSSL 1.1.0. The minimum recommend version is 1.0.2.                                          |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | 3DES has been removed from the default cipher suites and ChaCha20 Poly1305 cipher suites have been added.    |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | *SSLContext* has better default configuration for options and ciphers.                                       |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | SSL session can be copied from one client-side connection to another with the new *SSLSession* class. TLS    |                |
  | session resumption can speed up the initial handshake, reduce latency and improve performance.               |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | The new *get_ciphers()* method can be used to get a list of enabled ciphers in order of cipher priority.     |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | All constants and flags have been converted to *IntEnum* and *IntFlags*.                                     |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | Server and client-side specific TLS protocols for *SSLContext* were added.                                   |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | Added *SSLContext.post_handshake_auth* to enable and *ssl.SSLSocket.verify_client_post_handshake()* to       |                |
  | initiate TLS 1.3 post-handshake authentication.                                                              |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | `struct <https://docs.python.org/3.6/whatsnew/3.6.html#struct>`_                                             |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | now supports IEEE 754 half-precision floats via the 'e' format specifier.                                    |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | `sys <https://docs.python.org/3.6/whatsnew/3.6.html#sys>`_                                                   |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | The new *getfilesystemencodeerrors()* function returns the name of the error mode used to convert between    |                |
  | Unicode filenames and bytes filenames.                                                                       |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | `zlib <https://docs.python.org/3.6/whatsnew/3.6.html#zlib>`_                                                 |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+
  | The *compress()* and *decompress()* functions now accept keyword arguments                                   |                |
  +--------------------------------------------------------------------------------------------------------------+----------------+