2012-09-30 15:11:58 +08:00
|
|
|
****************************
|
|
|
|
What's New In Python 3.4
|
|
|
|
****************************
|
|
|
|
|
2012-10-28 20:37:54 +08:00
|
|
|
.. :Author: Someone <email>
|
|
|
|
(uncomment if there is a principal author)
|
2012-09-30 15:11:58 +08:00
|
|
|
|
|
|
|
.. Rules for maintenance:
|
|
|
|
|
2012-09-30 21:21:53 +08:00
|
|
|
* Anyone can add text to this document, but the maintainer reserves the
|
|
|
|
right to rewrite any additions. In particular, for obscure or esoteric
|
|
|
|
features, the maintainer may reduce any addition to a simple reference to
|
|
|
|
the new documentation rather than explaining the feature inline.
|
|
|
|
|
|
|
|
* While the maintainer will periodically go through Misc/NEWS
|
|
|
|
and add changes, it's best not to rely on this. We know from experience
|
|
|
|
that any changes that aren't in the What's New documentation around the
|
|
|
|
time of the original release will remain largely unknown to the community
|
|
|
|
for years, even if they're added later. We also know from experience that
|
|
|
|
other priorities can arise, and the maintainer will run out of time to do
|
|
|
|
updates - in such cases, end users will be much better served by partial
|
|
|
|
notifications that at least give a hint about new features to
|
|
|
|
investigate.
|
2012-09-30 15:11:58 +08:00
|
|
|
|
|
|
|
* This is not a complete list of every single change; completeness
|
2012-09-30 21:21:53 +08:00
|
|
|
is the purpose of Misc/NEWS. The What's New should focus on changes that
|
|
|
|
are visible to Python *users* and that *require* a feature release (i.e.
|
|
|
|
most bug fixes should only be recorded in Misc/NEWS)
|
|
|
|
|
|
|
|
* PEPs should not be marked Final until they have an entry in What's New.
|
|
|
|
A placeholder entry that is just a section header and a link to the PEP
|
|
|
|
(e.g ":pep:`397` has been implemented") is acceptable. If a PEP has been
|
|
|
|
implemented and noted in What's New, don't forget to mark it as Final!
|
2012-09-30 15:11:58 +08:00
|
|
|
|
|
|
|
* If you want to draw your new text to the attention of the
|
|
|
|
maintainer, add 'XXX' to the beginning of the paragraph or
|
|
|
|
section.
|
|
|
|
|
2012-09-30 21:21:53 +08:00
|
|
|
* It's OK to add just a very brief note about a change. For
|
|
|
|
example: "The :ref:`~socket.transmogrify()` function was added to the
|
|
|
|
:mod:`socket` module." The maintainer will research the change and
|
|
|
|
write the necessary text (if appropriate). The advantage of doing this
|
|
|
|
is that even if no more descriptive text is ever added, readers will at
|
|
|
|
least have a notification that the new feature exists and a link to the
|
|
|
|
relevant documentation.
|
2012-09-30 15:11:58 +08:00
|
|
|
|
|
|
|
* You can comment out your additions if you like, but it's not
|
|
|
|
necessary (especially when a final release is some months away).
|
|
|
|
|
|
|
|
* Credit the author of a patch or bugfix. Just the name is
|
|
|
|
sufficient; the e-mail address isn't necessary.
|
|
|
|
|
|
|
|
* It's helpful to add the bug/patch number as a comment:
|
|
|
|
|
2012-09-30 21:21:53 +08:00
|
|
|
The :ref:`~socket.transmogrify()` function was added to the
|
|
|
|
:mod:`socket` module. (Contributed by P.Y. Developer in :issue:`12345`.)
|
2012-09-30 15:11:58 +08:00
|
|
|
|
|
|
|
This saves the maintainer the effort of going through the Mercurial log
|
|
|
|
when researching a change.
|
|
|
|
|
2012-09-30 21:21:53 +08:00
|
|
|
* Cross referencing tip: :ref:`mod.attr` will display as ``mod.attr``,
|
|
|
|
while :ref:`~mod.attr` will display as ``attr``.
|
|
|
|
|
2012-09-30 15:11:58 +08:00
|
|
|
This article explains the new features in Python 3.4, compared to 3.3.
|
|
|
|
|
2012-09-30 21:21:53 +08:00
|
|
|
.. Python 3.4 was released on TBD.
|
2012-09-30 15:11:58 +08:00
|
|
|
|
2012-11-18 01:30:48 +08:00
|
|
|
For full details, see the
|
|
|
|
`changelog <http://docs.python.org/3.4/whatsnew/changelog.html>`_.
|
2012-09-30 15:11:58 +08:00
|
|
|
|
|
|
|
.. note:: Prerelease users should be aware that this document is currently in
|
|
|
|
draft form. It will be updated substantially as Python 3.4 moves towards
|
|
|
|
release, so it's worth checking back even after reading earlier versions.
|
|
|
|
|
|
|
|
|
|
|
|
.. seealso::
|
|
|
|
|
2012-09-30 21:21:53 +08:00
|
|
|
.. :pep:`4XX` - Python 3.4 Release Schedule
|
2012-09-30 15:11:58 +08:00
|
|
|
|
|
|
|
|
|
|
|
Summary -- Release highlights
|
|
|
|
=============================
|
|
|
|
|
2013-03-26 21:56:14 +08:00
|
|
|
.. This section singles out the most important changes in Python 3.4.
|
2012-09-30 15:11:58 +08:00
|
|
|
Brevity is key.
|
|
|
|
|
|
|
|
New syntax features:
|
|
|
|
|
|
|
|
* None yet.
|
|
|
|
|
|
|
|
New library modules:
|
|
|
|
|
2013-06-21 06:31:55 +08:00
|
|
|
* :mod:`enum`: Implementation of the :pep:`435`.
|
2013-09-05 02:30:34 +08:00
|
|
|
* :mod:`selectors`: High-level and efficient I/O multiplexing, built upon the
|
|
|
|
:mod:`select` module primitives.
|
2012-09-30 15:11:58 +08:00
|
|
|
|
|
|
|
New built-in features:
|
|
|
|
|
2013-08-13 02:46:47 +08:00
|
|
|
* :ref:`PEP 442: Safe object finalization <pep-442>`.
|
|
|
|
* :ref:`PEP 445: Configurable memory allocators <pep-445>`.
|
2013-08-28 06:53:59 +08:00
|
|
|
* :ref:`PEP 446: Make newly created file descriptors non-inheritable <pep-446>`.
|
2012-09-30 15:11:58 +08:00
|
|
|
|
|
|
|
Implementation improvements:
|
|
|
|
|
2013-08-13 02:46:47 +08:00
|
|
|
* A more efficient :mod:`marshal` format (:issue:`16475`).
|
|
|
|
* Improve finalization of Python modules to avoid setting their globals
|
|
|
|
to None, in most cases (:issue:`18214`).
|
2012-09-30 15:11:58 +08:00
|
|
|
|
|
|
|
Significantly Improved Library Modules:
|
|
|
|
|
2013-08-13 02:46:47 +08:00
|
|
|
* Single-dispatch generic functions (:pep:`443`)
|
|
|
|
* SHA-3 (Keccak) support for :mod:`hashlib`.
|
|
|
|
* TLSv1.1 and TLSv1.2 support for :mod:`ssl`.
|
2013-08-14 22:35:41 +08:00
|
|
|
* :mod:`multiprocessing` now has option to avoid using :func:`os.fork`
|
|
|
|
on Unix (:issue:`8713`).
|
2013-08-13 02:46:47 +08:00
|
|
|
|
2012-09-30 15:11:58 +08:00
|
|
|
Security improvements:
|
|
|
|
|
2013-08-10 22:36:18 +08:00
|
|
|
* command line option for :ref:`isolated mode <using-on-misc-options>`,
|
|
|
|
:issue:`16499`.
|
2012-09-30 15:11:58 +08:00
|
|
|
|
|
|
|
Please read on for a comprehensive list of user-facing changes.
|
|
|
|
|
2013-08-28 06:53:59 +08:00
|
|
|
.. _pep-446:
|
|
|
|
|
|
|
|
PEP 446: Make newly created file descriptors non-inheritable
|
|
|
|
============================================================
|
|
|
|
|
2013-09-15 16:37:57 +08:00
|
|
|
The :pep:`446` makes newly created file descriptors :ref:`non-inheritable
|
|
|
|
<fd_inheritance>`. New functions and methods:
|
2013-08-28 06:53:59 +08:00
|
|
|
|
|
|
|
* :func:`os.get_inheritable`, :func:`os.set_inheritable`
|
|
|
|
* :func:`os.get_handle_inheritable`, :func:`os.set_handle_inheritable`
|
|
|
|
* :meth:`socket.socket.get_inheritable`, :meth:`socket.socket.set_inheritable`
|
|
|
|
|
|
|
|
|
2013-08-13 02:46:47 +08:00
|
|
|
.. _pep-445:
|
|
|
|
|
|
|
|
PEP 445: Add new APIs to customize Python memory allocators
|
|
|
|
===========================================================
|
2012-09-30 15:11:58 +08:00
|
|
|
|
2013-07-07 08:05:46 +08:00
|
|
|
The :pep:`445` adds new Application Programming Interfaces (API) to customize
|
|
|
|
Python memory allocators.
|
2012-09-30 15:11:58 +08:00
|
|
|
|
|
|
|
|
2013-07-31 01:59:21 +08:00
|
|
|
.. _pep-442:
|
|
|
|
|
|
|
|
PEP 442: Safe object finalization
|
|
|
|
=================================
|
|
|
|
|
|
|
|
This PEP removes the current limitations and quirks of object finalization.
|
|
|
|
With it, objects with :meth:`__del__` methods, as well as generators
|
|
|
|
with :keyword:`finally` clauses, can be finalized when they are part of a
|
|
|
|
reference cycle.
|
|
|
|
|
|
|
|
.. seealso::
|
|
|
|
|
|
|
|
:pep:`442` - Safe object finalization
|
|
|
|
PEP written and implemented by Antoine Pitrou
|
|
|
|
|
2012-09-30 15:11:58 +08:00
|
|
|
|
|
|
|
Other Language Changes
|
|
|
|
======================
|
|
|
|
|
|
|
|
Some smaller changes made to the core Python language are:
|
|
|
|
|
2012-09-30 20:39:18 +08:00
|
|
|
* Unicode database updated to UCD version 6.2.
|
2012-09-30 15:11:58 +08:00
|
|
|
|
2013-06-29 01:31:19 +08:00
|
|
|
* :func:`min` and :func:`max` now accept a *default* argument that can be used
|
|
|
|
to specify the value they return if the iterable they are evaluating has no
|
|
|
|
elements. Contributed by Julian Berman in :issue:`18111`.
|
2012-09-30 15:11:58 +08:00
|
|
|
|
2013-08-13 02:46:47 +08:00
|
|
|
* Module objects are now :mod:`weakref`'able.
|
|
|
|
|
2012-09-30 15:11:58 +08:00
|
|
|
|
|
|
|
New Modules
|
|
|
|
===========
|
|
|
|
|
2013-09-05 01:02:49 +08:00
|
|
|
selectors
|
|
|
|
---------
|
2012-09-30 15:11:58 +08:00
|
|
|
|
2013-09-05 01:02:49 +08:00
|
|
|
The new :mod:`selectors` module allows high-level and efficient I/O
|
|
|
|
multiplexing, built upon the :mod:`select` module primitives.
|
2012-09-30 15:11:58 +08:00
|
|
|
|
|
|
|
|
|
|
|
Improved Modules
|
|
|
|
================
|
|
|
|
|
2013-08-13 02:48:15 +08:00
|
|
|
aifc
|
|
|
|
----
|
|
|
|
|
|
|
|
The :meth:`~aifc.getparams` method now returns a namedtuple rather than a
|
|
|
|
plain tuple. (Contributed by Claudiu Popa in :issue:`17818`.)
|
|
|
|
|
|
|
|
|
|
|
|
colorsys
|
|
|
|
--------
|
|
|
|
|
|
|
|
The number of digits in the coefficients for the RGB --- YIQ conversions have
|
|
|
|
been expanded so that they match the FCC NTSC versions. The change in
|
|
|
|
results should be less than 1% and may better match results found elsewhere.
|
|
|
|
|
2013-04-14 02:49:48 +08:00
|
|
|
|
2013-05-06 21:59:20 +08:00
|
|
|
dis
|
|
|
|
---
|
|
|
|
|
|
|
|
The :mod:`dis` module is now built around an :class:`Instruction` class that
|
|
|
|
provides details of individual bytecode operations and a
|
|
|
|
:func:`get_instructions` iterator that emits the Instruction stream for a
|
|
|
|
given piece of Python code. The various display tools in the :mod:`dis`
|
|
|
|
module have been updated to be based on these new components.
|
|
|
|
|
|
|
|
The new :class:`dis.Bytecode` class provides an object-oriented API for
|
|
|
|
inspecting bytecode, both in human-readable form and for iterating over
|
|
|
|
instructions.
|
|
|
|
|
|
|
|
(Contributed by Nick Coghlan, Ryan Kelly and Thomas Kluyver in :issue:`11816`)
|
|
|
|
|
2013-08-13 02:48:15 +08:00
|
|
|
|
2012-11-22 04:09:21 +08:00
|
|
|
doctest
|
|
|
|
-------
|
|
|
|
|
2013-06-24 02:24:13 +08:00
|
|
|
Added :data:`~doctest.FAIL_FAST` flag to halt test running as soon as the first
|
|
|
|
failure is detected. (Contributed by R. David Murray and Daniel Urban in
|
|
|
|
:issue:`16522`.)
|
|
|
|
|
|
|
|
Updated the doctest command line interface to use :mod:`argparse`, and added
|
|
|
|
``-o`` and ``-f`` options to the interface. ``-o`` allows doctest options to
|
|
|
|
be specified on the command line, and ``-f`` is a shorthand for ``-o
|
|
|
|
FAIL_FAST`` (to parallel the similar option supported by the :mod:`unittest`
|
|
|
|
CLI). (Contributed by R. David Murray in :issue:`11390`.)
|
2012-09-30 15:11:58 +08:00
|
|
|
|
2013-04-14 02:49:48 +08:00
|
|
|
|
2013-08-10 04:15:28 +08:00
|
|
|
email
|
|
|
|
-----
|
|
|
|
|
|
|
|
:meth:`~email.message.Message.as_string` now accepts a *policy* argument to
|
|
|
|
override the default policy of the message when generating a string
|
|
|
|
representation of it. This means that ``as_string`` can now be used in more
|
|
|
|
circumstances, instead of having to create and use a :mod:`~email.generator` in
|
|
|
|
order to pass formatting parameters to its ``flatten`` method.
|
|
|
|
|
|
|
|
New method :meth:`~email.message.Message.as_bytes` added to produce a bytes
|
|
|
|
representation of the message in a fashion similar to how ``as_string``
|
|
|
|
produces a string representation. It does not accept the *maxheaderlen*
|
|
|
|
argument, but does accept the *unixfrom* and *policy* arguments. The
|
|
|
|
:class:`~email.message.Message` :meth:`~email.message.Message.__bytes__` method
|
|
|
|
calls it, meaning that ``bytes(mymsg)`` will now produce the intuitive
|
|
|
|
result: a bytes object containing the fully formatted message.
|
|
|
|
|
|
|
|
(Contributed by R. David Murray in :issue:`18600`.)
|
|
|
|
|
|
|
|
|
2013-06-21 06:36:30 +08:00
|
|
|
functools
|
|
|
|
---------
|
|
|
|
|
|
|
|
New :func:`functools.singledispatch` decorator: see the :pep:`443`.
|
|
|
|
|
2013-07-28 18:00:01 +08:00
|
|
|
|
2013-08-13 02:48:15 +08:00
|
|
|
inspect
|
|
|
|
-------
|
|
|
|
|
|
|
|
:func:`~inspect.unwrap` makes it easy to unravel wrapper function chains
|
|
|
|
created by :func:`functools.wraps` (and any other API that sets the
|
|
|
|
``__wrapped__`` attribute on a wrapper function).
|
|
|
|
|
|
|
|
|
2013-08-13 02:46:47 +08:00
|
|
|
mmap
|
|
|
|
----
|
|
|
|
|
|
|
|
mmap objects can now be weakref'ed.
|
|
|
|
|
|
|
|
(Contributed by Valerie Lambert in :issue:`4885`.)
|
|
|
|
|
|
|
|
|
2013-08-14 22:35:41 +08:00
|
|
|
multiprocessing
|
|
|
|
---------------
|
|
|
|
|
|
|
|
On Unix two new *start methods* have been added for starting processes
|
|
|
|
using :mod:`multiprocessing`. These make the mixing of processes with
|
|
|
|
threads more robust. See :issue:`8713`.
|
|
|
|
|
|
|
|
Also, except when using the old *fork* start method, child processes
|
|
|
|
will no longer inherit unneeded handles/file descriptors from their parents.
|
|
|
|
|
|
|
|
|
2013-08-28 06:53:59 +08:00
|
|
|
os
|
|
|
|
--
|
|
|
|
|
|
|
|
New functions to get and set the `inheritable flag <fd_inheritance>`_ of a file
|
|
|
|
descriptors or a Windows handle:
|
|
|
|
|
|
|
|
* :func:`os.get_inheritable`, :func:`os.set_inheritable`
|
|
|
|
* :func:`os.get_handle_inheritable`, :func:`os.set_handle_inheritable`
|
|
|
|
|
|
|
|
|
2013-08-13 02:46:47 +08:00
|
|
|
poplib
|
|
|
|
------
|
|
|
|
|
|
|
|
New :meth:`~poplib.POP3.stls` method to switch a clear-text POP3 session into
|
|
|
|
an encrypted POP3 session.
|
|
|
|
|
|
|
|
New :meth:`~poplib.POP3.capa` method to query the capabilities advertised by the
|
|
|
|
POP3 server.
|
|
|
|
|
|
|
|
(Contributed by Lorenzo Catucci in :issue:`4473`.)
|
|
|
|
|
|
|
|
|
2013-04-14 02:49:48 +08:00
|
|
|
smtplib
|
|
|
|
-------
|
|
|
|
|
2013-04-14 18:46:35 +08:00
|
|
|
:exc:`~smtplib.SMTPException` is now a subclass of :exc:`OSError`, which allows
|
2013-04-14 02:49:48 +08:00
|
|
|
both socket level errors and SMTP protocol level errors to be caught in one
|
|
|
|
try/except statement by code that only cares whether or not an error occurred.
|
|
|
|
(:issue:`2118`).
|
|
|
|
|
2013-08-13 02:48:15 +08:00
|
|
|
|
2013-08-28 06:53:59 +08:00
|
|
|
socket
|
|
|
|
------
|
|
|
|
|
2013-09-15 16:37:57 +08:00
|
|
|
Socket objects have new methods to get or set their :ref:`inheritable flag
|
|
|
|
<fd_inheritance>`:
|
2013-08-28 06:53:59 +08:00
|
|
|
|
|
|
|
* :meth:`socket.socket.get_inheritable`, :meth:`socket.socket.set_inheritable`
|
|
|
|
|
2013-09-01 06:18:48 +08:00
|
|
|
The ``socket.AF_*`` and ``socket.SOCK_*`` constants are enumeration values,
|
|
|
|
using the new :mod:`enum` module. This allows descriptive reporting during
|
|
|
|
debugging, instead of seeing integer "magic numbers".
|
2013-08-28 06:53:59 +08:00
|
|
|
|
2013-06-23 01:31:58 +08:00
|
|
|
ssl
|
|
|
|
---
|
|
|
|
|
2013-08-13 02:46:47 +08:00
|
|
|
TLSv1.1 and TLSv1.2 support.
|
|
|
|
|
|
|
|
(Contributed by Michele Orrù and Antoine Pitrou in :issue:`16692`)
|
2013-06-23 01:34:17 +08:00
|
|
|
|
2013-08-13 02:46:47 +08:00
|
|
|
* New diagnostic functions :func:`~ssl.get_default_verify_paths`,
|
|
|
|
:meth:`~ssl.SSLContext.cert_store_stats` and
|
|
|
|
:meth:`~ssl.SSLContext.get_ca_certs`
|
2013-06-23 01:31:58 +08:00
|
|
|
|
2013-08-13 02:46:47 +08:00
|
|
|
* Add :func:`ssl.enum_cert_store` to retrieve certificates and CRL from Windows'
|
|
|
|
cert store.
|
2013-06-23 01:31:58 +08:00
|
|
|
|
|
|
|
(Contributed by Christian Heimes in :issue:`18143`, :issue:`18147` and
|
2013-08-13 02:46:47 +08:00
|
|
|
:issue:`17134`.)
|
|
|
|
|
|
|
|
Support for server-side SNI using the new
|
|
|
|
:meth:`ssl.SSLContext.set_servername_callback` method.
|
|
|
|
|
|
|
|
(Contributed by Daniel Black in :issue:`8109`.)
|
|
|
|
|
|
|
|
|
2013-08-13 02:48:15 +08:00
|
|
|
stat
|
|
|
|
----
|
|
|
|
|
|
|
|
The :mod:`stat` module is now backed by a C implementation in :mod:`_stat`. A C
|
|
|
|
implementation is required as most of the values aren't standardized and
|
|
|
|
platform-dependent. (Contributed by Christian Heimes in :issue:`11016`.)
|
|
|
|
|
|
|
|
The module supports new file types: door, event port and whiteout.
|
|
|
|
|
|
|
|
|
2013-08-13 02:46:47 +08:00
|
|
|
struct
|
|
|
|
------
|
|
|
|
|
|
|
|
Streaming struct unpacking using :func:`struct.iter_unpack`.
|
|
|
|
|
|
|
|
(Contributed by Antoine Pitrou in :issue:`17804`.)
|
|
|
|
|
|
|
|
|
2013-09-04 05:43:03 +08:00
|
|
|
sunau
|
|
|
|
-----
|
|
|
|
|
|
|
|
The :meth:`~sunau.getparams` method now returns a namedtuple rather than a
|
|
|
|
plain tuple. (Contributed by Claudiu Popa in :issue:`18901`.)
|
|
|
|
|
2013-09-05 22:01:53 +08:00
|
|
|
:meth:`sunau.open` now supports the context manager protocol (:issue:`18878`).
|
|
|
|
|
2013-09-04 05:43:03 +08:00
|
|
|
|
2013-09-16 06:15:56 +08:00
|
|
|
traceback
|
|
|
|
---------
|
|
|
|
|
|
|
|
A new :func:`traceback.clear_frames` function takes a traceback object
|
|
|
|
and clears the local variables in all of the frames it references,
|
|
|
|
reducing the amount of memory consumed (:issue:`1565525`).
|
|
|
|
|
|
|
|
|
2013-08-13 02:46:47 +08:00
|
|
|
urllib
|
|
|
|
------
|
|
|
|
|
|
|
|
Add support.for ``data:`` URLs in :mod:`urllib.request`.
|
|
|
|
|
|
|
|
(Contributed by Mathias Panzenböck in :issue:`16423`.)
|
|
|
|
|
|
|
|
|
|
|
|
unittest
|
|
|
|
--------
|
|
|
|
|
|
|
|
Support for easy dynamically-generated subtests using the
|
|
|
|
:meth:`~unittest.TestCase.subTest` context manager.
|
|
|
|
|
|
|
|
(Contributed by Antoine Pitrou in :issue:`16997`.)
|
|
|
|
|
2013-04-14 02:49:48 +08:00
|
|
|
|
2013-04-11 00:31:43 +08:00
|
|
|
wave
|
|
|
|
----
|
|
|
|
|
|
|
|
The :meth:`~wave.getparams` method now returns a namedtuple rather than a
|
|
|
|
plain tuple. (Contributed by Claudiu Popa in :issue:`17487`.)
|
|
|
|
|
2013-08-01 01:46:08 +08:00
|
|
|
:meth:`wave.open` now supports the context manager protocol. (Contributed
|
|
|
|
by Claudiu Popa in :issue:`17616`.)
|
|
|
|
|
2013-08-13 02:46:47 +08:00
|
|
|
|
|
|
|
weakref
|
|
|
|
-------
|
|
|
|
|
|
|
|
New :class:`~weakref.WeakMethod` class simulates weak references to bound
|
|
|
|
methods.
|
|
|
|
|
|
|
|
(Contributed by Antoine Pitrou in :issue:`14631`.)
|
|
|
|
|
|
|
|
|
|
|
|
xml.etree
|
|
|
|
---------
|
|
|
|
|
|
|
|
Add an event-driven parser for non-blocking applications,
|
2013-08-30 20:51:20 +08:00
|
|
|
:class:`~xml.etree.ElementTree.XMLPullParser`.
|
2013-08-13 02:46:47 +08:00
|
|
|
|
2013-08-30 20:51:20 +08:00
|
|
|
(Contributed by Antoine Pitrou in :issue:`17741`.)
|
2013-08-13 02:46:47 +08:00
|
|
|
|
|
|
|
Other improvements
|
|
|
|
==================
|
|
|
|
|
|
|
|
Tab-completion is now enabled by default in the interactive interpreter.
|
|
|
|
|
|
|
|
(Contributed by Antoine Pitrou and Éric Araujo in :issue:`5845`.)
|
|
|
|
|
2013-09-06 21:55:58 +08:00
|
|
|
Python invocation changes
|
|
|
|
=========================
|
|
|
|
|
|
|
|
Invoking the Python interpreter with ``--version`` now outputs the version to
|
|
|
|
standard output instead of standard error (:issue:`18338`). Similar changes
|
|
|
|
were made to :mod:`argparse` (:issue:`18920`) and other modules that have
|
|
|
|
script-like invocation capabilities (:issue:`18922`).
|
2013-08-13 02:46:47 +08:00
|
|
|
|
2012-09-30 15:11:58 +08:00
|
|
|
Optimizations
|
|
|
|
=============
|
|
|
|
|
|
|
|
Major performance enhancements have been added:
|
|
|
|
|
2012-10-31 06:12:47 +08:00
|
|
|
* The UTF-32 decoder is now 3x to 4x faster.
|
2012-09-30 15:11:58 +08:00
|
|
|
|
2013-08-20 00:12:20 +08:00
|
|
|
* The cost of hash collisions for sets is now reduced. Each hash table
|
2013-09-16 05:57:15 +08:00
|
|
|
probe now checks a series of consecutive, adjacent key/hash pairs before
|
|
|
|
continuing to make random probes through the hash table. This exploits
|
|
|
|
cache locality to make collision resolution less expensive.
|
|
|
|
|
|
|
|
The collision resolution scheme can be described as a hybrid of linear
|
|
|
|
probing and open addressing. The number of additional linear probes
|
|
|
|
defaults to nine. This can be changed at compile-time by defining
|
|
|
|
LINEAR_PROBES to be any value. Set LINEAR_PROBES=0 to turn-off
|
|
|
|
linear probing entirely.
|
2013-08-20 00:12:20 +08:00
|
|
|
|
2013-08-20 01:07:18 +08:00
|
|
|
(Contributed by Raymond Hettinger in :issue"`18771`.)
|
2013-08-20 00:12:20 +08:00
|
|
|
|
2012-09-30 15:11:58 +08:00
|
|
|
|
|
|
|
Build and C API Changes
|
|
|
|
=======================
|
|
|
|
|
|
|
|
Changes to Python's build process and to the C API include:
|
|
|
|
|
|
|
|
* None yet.
|
|
|
|
|
|
|
|
|
|
|
|
Deprecated
|
|
|
|
==========
|
|
|
|
|
|
|
|
Unsupported Operating Systems
|
|
|
|
-----------------------------
|
|
|
|
|
2013-08-04 16:30:57 +08:00
|
|
|
* OS/2
|
|
|
|
* Windows 2000
|
2012-09-30 15:11:58 +08:00
|
|
|
|
|
|
|
|
|
|
|
Deprecated Python modules, functions and methods
|
|
|
|
------------------------------------------------
|
|
|
|
|
2013-03-22 07:36:26 +08:00
|
|
|
* :meth:`difflib.SequenceMatcher.isbjunk` and
|
2013-06-16 01:29:09 +08:00
|
|
|
:meth:`difflib.SequenceMatcher.isbpopular` were removed: use ``x in sm.bjunk`` and
|
|
|
|
``x in sm.bpopular``, where *sm* is a :class:`~difflib.SequenceMatcher` object.
|
2012-09-30 15:11:58 +08:00
|
|
|
|
2013-06-15 10:37:11 +08:00
|
|
|
* :func:`importlib.util.module_for_loader` is pending deprecation. Using
|
|
|
|
:func:`importlib.util.module_to_load` and
|
|
|
|
:meth:`importlib.abc.Loader.init_module_attrs` allows subclasses of a loader
|
|
|
|
to more easily customize module loading.
|
|
|
|
|
2013-06-17 01:13:40 +08:00
|
|
|
* The :mod:`imp` module is pending deprecation. To keep compatibility with
|
|
|
|
Python 2/3 code bases, the module's removal is currently not scheduled.
|
|
|
|
|
2012-09-30 15:11:58 +08:00
|
|
|
|
|
|
|
Deprecated functions and types of the C API
|
|
|
|
-------------------------------------------
|
|
|
|
|
|
|
|
* None yet.
|
|
|
|
|
|
|
|
|
|
|
|
Deprecated features
|
|
|
|
-------------------
|
|
|
|
|
2013-06-15 10:37:11 +08:00
|
|
|
* None yet.
|
2012-09-30 15:11:58 +08:00
|
|
|
|
|
|
|
|
2012-10-05 00:45:10 +08:00
|
|
|
Porting to Python 3.4
|
2012-09-30 15:11:58 +08:00
|
|
|
=====================
|
|
|
|
|
|
|
|
This section lists previously described changes and other bugfixes
|
|
|
|
that may require changes to your code.
|
|
|
|
|
2013-04-10 05:03:10 +08:00
|
|
|
* The ABCs defined in :mod:`importlib.abc` now either raise the appropriate
|
|
|
|
exception or return a default value instead of raising
|
|
|
|
:exc:`NotImplementedError` blindly. This will only affect code calling
|
|
|
|
:func:`super` and falling through all the way to the ABCs. For compatibility,
|
|
|
|
catch both :exc:`NotImplementedError` or the appropriate exception as needed.
|
2013-05-05 01:56:58 +08:00
|
|
|
|
|
|
|
* The module type now initializes the :attr:`__package__` and :attr:`__loader__`
|
|
|
|
attributes to ``None`` by default. To determine if these attributes were set
|
|
|
|
in a backwards-compatible fashion, use e.g.
|
2013-05-29 06:35:54 +08:00
|
|
|
``getattr(module, '__loader__', None) is not None``.
|
|
|
|
|
|
|
|
* :meth:`importlib.util.module_for_loader` now sets ``__loader__`` and
|
|
|
|
``__package__`` unconditionally to properly support reloading. If this is not
|
|
|
|
desired then you will need to set these attributes manually. You can use
|
2013-06-01 06:02:11 +08:00
|
|
|
:func:`importlib.util.module_to_load` for module management.
|
2013-06-01 11:18:39 +08:00
|
|
|
|
|
|
|
* Import now resets relevant attributes (e.g. ``__name__``, ``__loader__``,
|
|
|
|
``__package__``, ``__file__``, ``__cached__``) unconditionally when reloading.
|
|
|
|
|
|
|
|
* Frozen packages no longer set ``__path__`` to a list containg the package name
|
|
|
|
but an empty list instead. Determing if a module is a package should be done
|
|
|
|
using ``hasattr(module, '__path__')``.
|
2013-06-13 11:29:18 +08:00
|
|
|
|
|
|
|
* :c:func:`PyErr_SetImportError` now sets :exc:`TypeError` when its **msg**
|
2013-07-05 05:48:16 +08:00
|
|
|
argument is not set. Previously only ``NULL`` was returned with no exception
|
|
|
|
set.
|
2013-06-15 06:33:00 +08:00
|
|
|
|
|
|
|
* :func:`py_compile.compile` now raises :exc:`FileExistsError` if the file path
|
|
|
|
it would write to is a symlink or a non-regular file. This is to act as a
|
|
|
|
warning that import will overwrite those files with a regular file regardless
|
|
|
|
of what type of file path they were originally.
|
2013-06-17 06:05:54 +08:00
|
|
|
|
|
|
|
* :meth:`importlib.abc.SourceLoader.get_source` no longer raises
|
|
|
|
:exc:`ImportError` when the source code being loaded triggers a
|
|
|
|
:exc:`SyntaxError` or :exc:`UnicodeDecodeError`. As :exc:`ImportError` is
|
|
|
|
meant to be raised only when source code cannot be found but it should, it was
|
|
|
|
felt to be over-reaching/overloading of that meaning when the source code is
|
|
|
|
found but improperly structured. If you were catching ImportError before and
|
|
|
|
wish to continue to ignore syntax or decoding issues, catch all three
|
2013-06-21 06:31:55 +08:00
|
|
|
exceptions now.
|
2013-07-15 19:13:08 +08:00
|
|
|
|
|
|
|
* :func:`functools.update_wrapper` and :func:`functools.wraps` now correctly
|
|
|
|
set the ``__wrapped__`` attribute even if the wrapped function had a
|
|
|
|
wrapped attribute set. This means ``__wrapped__`` attributes now correctly
|
|
|
|
link a stack of decorated functions rather than every ``__wrapped__``
|
|
|
|
attribute in the chain referring to the innermost function. Introspection
|
2013-07-28 18:00:01 +08:00
|
|
|
libraries that assumed the previous behaviour was intentional can use
|
|
|
|
:func:`inspect.unwrap` to gain equivalent behaviour.
|