| Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 1 | **************************** |
| 2 | What's New In Python 3.5 |
| 3 | **************************** |
| 4 | |
| 5 | :Release: |release| |
| 6 | :Date: |today| |
| 7 | |
| 8 | .. Rules for maintenance: |
| 9 | |
| 10 | * Anyone can add text to this document. Do not spend very much time |
| 11 | on the wording of your changes, because your text will probably |
| 12 | get rewritten to some degree. |
| 13 | |
| 14 | * The maintainer will go through Misc/NEWS periodically and add |
| 15 | changes; it's therefore more important to add your changes to |
| 16 | Misc/NEWS than to this file. |
| 17 | |
| 18 | * This is not a complete list of every single change; completeness |
| 19 | is the purpose of Misc/NEWS. Some changes I consider too small |
| 20 | or esoteric to include. If such a change is added to the text, |
| 21 | I'll just remove it. (This is another reason you shouldn't spend |
| 22 | too much time on writing your addition.) |
| 23 | |
| 24 | * If you want to draw your new text to the attention of the |
| 25 | maintainer, add 'XXX' to the beginning of the paragraph or |
| 26 | section. |
| 27 | |
| 28 | * It's OK to just add a fragmentary note about a change. For |
| 29 | example: "XXX Describe the transmogrify() function added to the |
| 30 | socket module." The maintainer will research the change and |
| 31 | write the necessary text. |
| 32 | |
| 33 | * You can comment out your additions if you like, but it's not |
| 34 | necessary (especially when a final release is some months away). |
| 35 | |
| 36 | * Credit the author of a patch or bugfix. Just the name is |
| 37 | sufficient; the e-mail address isn't necessary. |
| 38 | |
| 39 | * It's helpful to add the bug/patch number as a comment: |
| 40 | |
| 41 | XXX Describe the transmogrify() function added to the socket |
| 42 | module. |
| 43 | (Contributed by P.Y. Developer in :issue:`12345`.) |
| 44 | |
| 45 | This saves the maintainer the effort of going through the Mercurial log |
| 46 | when researching a change. |
| 47 | |
| 48 | This article explains the new features in Python 3.5, compared to 3.4. |
| 49 | |
| 50 | For full details, see the :source:`Misc/NEWS` file. |
| 51 | |
| 52 | .. note:: Prerelease users should be aware that this document is currently in |
| 53 | draft form. It will be updated substantially as Python 3.5 moves towards |
| 54 | release, so it's worth checking back even after reading earlier versions. |
| 55 | |
| 56 | |
| 57 | .. seealso:: |
| 58 | |
| 59 | .. :pep:`4XX` - Python 3.5 Release Schedule |
| 60 | |
| 61 | |
| 62 | Summary -- Release highlights |
| 63 | ============================= |
| 64 | |
| 65 | .. This section singles out the most important changes in Python 3.3. |
| 66 | Brevity is key. |
| 67 | |
| 68 | New syntax features: |
| 69 | |
| 70 | * None yet. |
| 71 | |
| 72 | New library modules: |
| 73 | |
| 74 | * None yet. |
| 75 | |
| 76 | New built-in features: |
| 77 | |
| 78 | * None yet. |
| 79 | |
| 80 | Implementation improvements: |
| 81 | |
| Victor Stinner | 7143029 | 2014-03-18 01:18:21 +0100 | [diff] [blame] | 82 | * When the ``LC_TYPE`` locale is the POSIX locale (``C`` locale), |
| 83 | :py:data:`sys.stdin` and :py:data:`sys.stdout` are now using the |
| 84 | ``surrogateescape`` error handler, instead of the ``strict`` error handler |
| 85 | (:issue:`19977`). |
| Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 86 | |
| 87 | Significantly Improved Library Modules: |
| 88 | |
| 89 | * None yet. |
| 90 | |
| 91 | Security improvements: |
| 92 | |
| 93 | * None yet. |
| 94 | |
| 95 | Please read on for a comprehensive list of user-facing changes. |
| 96 | |
| 97 | |
| 98 | .. PEP-sized items next. |
| 99 | |
| 100 | .. _pep-4XX: |
| 101 | |
| 102 | .. PEP 4XX: Virtual Environments |
| 103 | .. ============================= |
| 104 | |
| 105 | |
| 106 | .. (Implemented by Foo Bar.) |
| 107 | |
| 108 | .. .. seealso:: |
| 109 | |
| 110 | :pep:`4XX` - Python Virtual Environments |
| 111 | PEP written by Carl Meyer |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | Other Language Changes |
| 117 | ====================== |
| 118 | |
| 119 | Some smaller changes made to the core Python language are: |
| 120 | |
| 121 | * None yet. |
| 122 | |
| 123 | |
| 124 | |
| 125 | New Modules |
| 126 | =========== |
| 127 | |
| 128 | .. module name |
| 129 | .. ----------- |
| 130 | |
| 131 | * None yet. |
| 132 | |
| 133 | |
| 134 | Improved Modules |
| 135 | ================ |
| 136 | |
| Antoine Pitrou | b9d9ce7 | 2014-05-15 22:47:33 +0200 | [diff] [blame] | 137 | doctest |
| 138 | ------- |
| Giampaolo Rodola' | e09fb71 | 2014-04-04 15:34:17 +0200 | [diff] [blame] | 139 | |
| Antoine Pitrou | b9d9ce7 | 2014-05-15 22:47:33 +0200 | [diff] [blame] | 140 | * :func:`doctest.DocTestSuite` returns an empty :class:`unittest.TestSuite` if |
| 141 | *module* contains no docstrings instead of raising :exc:`ValueError` |
| 142 | (contributed by Glenn Jones in :issue:`15916`). |
| 143 | |
| 144 | importlib |
| 145 | --------- |
| 146 | |
| 147 | * :class:`importlib.util.LazyLoader` allows for the lazy loading of modules in |
| 148 | applications where startup time is paramount (contributed by Brett Cannon in |
| 149 | :issue:`17621`). |
| 150 | |
| 151 | * :func:`importlib.abc.InspectLoader.source_to_code` is now a |
| 152 | static method to make it easier to work with source code in a string. |
| 153 | With a module object that you want to initialize you can then use |
| 154 | ``exec(code, module.__dict__)`` to execute the code in the module. |
| 155 | |
| Brett Cannon | 2a17bde | 2014-05-30 14:55:29 -0400 | [diff] [blame] | 156 | * :func:`importlib.util.module_from_spec` is now the preferred way to create a |
| 157 | new module. Compared to :class:`types.ModuleType`, this new function will set |
| 158 | the various import-controlled attributes based on the passed-in spec object. |
| 159 | |
| Antoine Pitrou | b9d9ce7 | 2014-05-15 22:47:33 +0200 | [diff] [blame] | 160 | inspect |
| 161 | ------- |
| Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 162 | |
| Yury Selivanov | a5d63dd | 2014-03-27 11:31:43 -0400 | [diff] [blame] | 163 | * :class:`inspect.Signature` and :class:`inspect.Parameter` are now |
| Yury Selivanov | 67ae50e | 2014-04-08 11:46:50 -0400 | [diff] [blame] | 164 | picklable and hashable (contributed by Yury Selivanov in :issue:`20726` |
| 165 | and :issue:`20334`). |
| Yury Selivanov | a5d63dd | 2014-03-27 11:31:43 -0400 | [diff] [blame] | 166 | |
| Yury Selivanov | da39645 | 2014-03-27 12:09:24 -0400 | [diff] [blame] | 167 | * New class method :meth:`inspect.Signature.from_callable`, which makes |
| 168 | subclassing of :class:`~inspect.Signature` easier (contributed |
| 169 | by Yury Selivanov and Eric Snow in :issue:`17373`). |
| 170 | |
| Antoine Pitrou | 0dfce56 | 2014-05-15 22:55:40 +0200 | [diff] [blame] | 171 | ipaddress |
| 172 | --------- |
| 173 | |
| 174 | * :class:`ipaddress.IPv4Network` and :class:`ipaddress.IPv6Network` now |
| 175 | accept an ``(address, netmask)`` tuple argument, so as to easily construct |
| 176 | network objects from existing addresses (contributed by Peter Moody |
| 177 | and Antoine Pitrou in :issue:`16531`). |
| 178 | |
| Antoine Pitrou | b9d9ce7 | 2014-05-15 22:47:33 +0200 | [diff] [blame] | 179 | signal |
| 180 | ------ |
| Brett Cannon | a04dbe4 | 2014-04-04 13:53:38 -0400 | [diff] [blame] | 181 | |
| Antoine Pitrou | b9d9ce7 | 2014-05-15 22:47:33 +0200 | [diff] [blame] | 182 | * Different constants of :mod:`signal` module are now enumeration values using |
| 183 | the :mod:`enum` module. This allows meaningful names to be printed during |
| 184 | debugging, instead of integer “magic numbers”. (contribute by Giampaolo |
| 185 | Rodola' in :issue:`21076`) |
| R David Murray | 1976d9b | 2014-04-14 20:28:36 -0400 | [diff] [blame] | 186 | |
| Antoine Pitrou | b9d9ce7 | 2014-05-15 22:47:33 +0200 | [diff] [blame] | 187 | xmlrpc |
| 188 | ------ |
| 189 | |
| 190 | * :class:`xmlrpc.client.ServerProxy` is now a :term:`context manager` |
| 191 | (contributed by Claudiu Popa in :issue:`20627`). |
| Brett Cannon | 6eaac13 | 2014-05-09 12:28:22 -0400 | [diff] [blame] | 192 | |
| Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 193 | |
| 194 | Optimizations |
| 195 | ============= |
| 196 | |
| Antoine Pitrou | b9d9ce7 | 2014-05-15 22:47:33 +0200 | [diff] [blame] | 197 | The following performance enhancements have been added: |
| Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 198 | |
| Victor Stinner | db067af | 2014-05-02 22:31:14 +0200 | [diff] [blame] | 199 | * Construction of ``bytes(int)`` and ``bytearray(int)`` (filled by zero bytes) |
| 200 | is faster and use less memory (until the bytearray buffer is filled with |
| 201 | data) for large objects. ``calloc()`` is used instead of ``malloc()`` to |
| 202 | allocate memory for these objects. |
| Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 203 | |
| Antoine Pitrou | 0dfce56 | 2014-05-15 22:55:40 +0200 | [diff] [blame] | 204 | * Some operations on :class:`~ipaddress.IPv4Network` and |
| 205 | :class:`~ipaddress.IPv6Network` have been massively sped up, such as |
| 206 | :meth:`~ipaddress.IPv4Network.subnets`, :meth:`~ipaddress.IPv4Network.supernet`, |
| 207 | :func:`~ipaddress.summarize_address_range`, :func:`~ipaddress.collapse_addresses`. |
| 208 | The speed up can range from 3x to 15x. |
| 209 | (:issue:`21486`, :issue:`21487`, :issue:`20826`) |
| 210 | |
| Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 211 | |
| 212 | Build and C API Changes |
| 213 | ======================= |
| 214 | |
| 215 | Changes to Python's build process and to the C API include: |
| 216 | |
| Victor Stinner | db067af | 2014-05-02 22:31:14 +0200 | [diff] [blame] | 217 | * New ``calloc`` functions: |
| 218 | |
| 219 | * :c:func:`PyMem_RawCalloc` |
| 220 | * :c:func:`PyMem_Calloc` |
| 221 | * :c:func:`PyObject_Calloc` |
| 222 | * :c:func:`_PyObject_GC_Calloc` |
| Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 223 | |
| 224 | |
| 225 | Deprecated |
| 226 | ========== |
| 227 | |
| 228 | Unsupported Operating Systems |
| 229 | ----------------------------- |
| 230 | |
| 231 | * None yet. |
| 232 | |
| 233 | |
| 234 | Deprecated Python modules, functions and methods |
| 235 | ------------------------------------------------ |
| 236 | |
| Brett Cannon | a77d0c3 | 2014-03-21 10:52:33 -0400 | [diff] [blame] | 237 | * The :mod:`formatter` module has now graduated to full deprecation and is still |
| 238 | slated for removal in Python 3.6. |
| Victor Stinner | 01adf06 | 2014-03-18 00:53:32 +0100 | [diff] [blame] | 239 | |
| 240 | |
| 241 | Deprecated functions and types of the C API |
| 242 | ------------------------------------------- |
| 243 | |
| 244 | * None yet. |
| 245 | |
| 246 | |
| 247 | Deprecated features |
| 248 | ------------------- |
| 249 | |
| 250 | * None yet. |
| 251 | |
| 252 | |
| 253 | Porting to Python 3.5 |
| 254 | ===================== |
| 255 | |
| 256 | This section lists previously described changes and other bugfixes |
| 257 | that may require changes to your code. |
| 258 | |
| Victor Stinner | db067af | 2014-05-02 22:31:14 +0200 | [diff] [blame] | 259 | Changes in the Python API |
| 260 | ------------------------- |
| 261 | |
| Benjamin Peterson | ee6bdc0 | 2014-03-20 18:00:35 -0500 | [diff] [blame] | 262 | * Before Python 3.5, a :class:`datetime.time` object was considered to be false |
| 263 | if it represented midnight in UTC. This behavior was considered obscure and |
| 264 | error-prone and has been removed in Python 3.5. See :issue:`13936` for full |
| 265 | details. |
| Antoine Pitrou | 92c4d45 | 2014-04-29 10:05:59 +0200 | [diff] [blame] | 266 | |
| 267 | * :meth:`ssl.SSLSocket.send()` now raises either :exc:`ssl.SSLWantReadError` |
| 268 | or :exc:`ssl.SSLWantWriteError` on a non-blocking socket if the operation |
| 269 | would block. Previously, it would return 0. See :issue:`20951`. |
| Victor Stinner | db067af | 2014-05-02 22:31:14 +0200 | [diff] [blame] | 270 | |
| 271 | Changes in the C API |
| 272 | -------------------- |
| 273 | |
| 274 | * The :c:type:`PyMemAllocator` structure has a new ``calloc`` field. |