summaryrefslogtreecommitdiffstats
path: root/Doc/whatsnew/2.7.rst
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-12-31 03:31:15 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-12-31 03:31:15 (GMT)
commit9eea4805f4c5db83282c1a8fe47e9f7560fd75cc (patch)
tree834f3835b3a0aa4aa0bceccfe17d80ae31613ea0 /Doc/whatsnew/2.7.rst
parentb2d90467927e953bd2c195b7d6de94744a13ce60 (diff)
downloadcpython-9eea4805f4c5db83282c1a8fe47e9f7560fd75cc.zip
cpython-9eea4805f4c5db83282c1a8fe47e9f7560fd75cc.tar.gz
cpython-9eea4805f4c5db83282c1a8fe47e9f7560fd75cc.tar.bz2
Merged revisions 76852,77001,77115,77127 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r76852 | benjamin.peterson | 2009-12-15 21:36:22 -0600 (Tue, 15 Dec 2009) | 1 line remove type_compare, since type_richcompare does the same trick ........ r77001 | brett.cannon | 2009-12-21 20:37:37 -0600 (Mon, 21 Dec 2009) | 1 line Make a word plural. ........ r77115 | andrew.kuchling | 2009-12-29 14:10:16 -0600 (Tue, 29 Dec 2009) | 1 line Various additions ........ r77127 | andrew.kuchling | 2009-12-29 17:41:04 -0600 (Tue, 29 Dec 2009) | 1 line Add various items ........
Diffstat (limited to 'Doc/whatsnew/2.7.rst')
-rw-r--r--Doc/whatsnew/2.7.rst159
1 files changed, 132 insertions, 27 deletions
diff --git a/Doc/whatsnew/2.7.rst b/Doc/whatsnew/2.7.rst
index 768ea33..4171593 100644
--- a/Doc/whatsnew/2.7.rst
+++ b/Doc/whatsnew/2.7.rst
@@ -49,9 +49,9 @@
This saves the maintainer some effort going through the SVN logs
when researching a change.
-This article explains the new features in Python 2.7. No release
-schedule has been decided yet for 2.7; the schedule will eventually be
-described in :pep:`373`.
+This article explains the new features in Python 2.7. The final
+release of 2.7 is currently scheduled for June 2010; the detailed
+schedule is described in :pep:`373`.
.. Compare with previous release in 2 - 3 sentences here.
add hyperlink when the documentation becomes available online.
@@ -73,6 +73,11 @@ A partial list of 3.1 features that were backported to 2.7:
* The new format specifier described in :ref:`pep-0378`.
* The :class:`memoryview` object.
* A small subset of the :mod:`importlib` module `described below <#importlib-section>`__.
+* Float-to-string and string-to-float conversions now round their
+ results more correctly. And :func:`repr` of a floating-point
+ number *x* returns a result that's guaranteed to round back to the
+ same number when converted back to a string.
+* The :cfunc:`PyLong_AsLongAndOverflow` C API function.
One porting change: the :option:`-3` switch now automatically
enables the :option:`-Qwarn` switch that causes warnings
@@ -237,6 +242,33 @@ Some smaller changes made to the core Python language are:
(Proposed in http://codereview.appspot.com/53094; implemented by
Georg Brandl.)
+* Conversions between floating-point numbers and strings are
+ now correctly rounded on most platforms. These conversions occur
+ in many different places: :func:`str` on
+ floats and complex numbers; the :class:`float` and :class:`complex`
+ constructors;
+ numeric formatting; serialization and
+ deserialization of floats and complex numbers using the
+ :mod:`marshal`, :mod:`pickle`
+ and :mod:`json` modules;
+ parsing of float and imaginary literals in Python code;
+ and :class:`Decimal`-to-float conversion.
+
+ Related to this, the :func:`repr` of a floating-point number *x*
+ now returns a result based on the shortest decimal string that's
+ guaranteed to round back to *x* under correct rounding (with
+ round-half-to-even rounding mode). Previously it gave a string
+ based on rounding x to 17 decimal digits.
+
+ The rounding library responsible for this improvement works on
+ Windows, and on Unix platforms using the gcc, icc, or suncc
+ compilers. There may be a small number of platforms where correct
+ operation of this code cannot be guaranteed, so the code is not
+ used on such systems.
+
+ Implemented by Mark Dickinson, using David Gay's :file:`dtoa.c` library;
+ :issue:`7117`.
+
* The :meth:`str.format` method now supports automatic numbering of the replacement
fields. This makes using :meth:`str.format` more closely resemble using
``%s`` formatting::
@@ -259,6 +291,10 @@ Some smaller changes made to the core Python language are:
alignment is applied to the whole of the resulting ``1.5+3j``
output. (Contributed by Eric Smith; :issue:`1588`.)
+ The 'F' format code now always formats its output using uppercase characters,
+ so it will now produce 'INF' and 'NAN'.
+ (Contributed by Eric Smith; :issue:`3382`.)
+
* The :func:`int` and :func:`long` types gained a ``bit_length``
method that returns the number of bits necessary to represent
its argument in binary::
@@ -301,6 +337,9 @@ Some smaller changes made to the core Python language are:
(Implemented by Mark Dickinson; :issue:`3166`.)
+ Integer division is also more accurate in its rounding behaviours. (Also
+ implemented by Mark Dickinson; :issue:`1811`.)
+
* The :class:`bytearray` type's :meth:`translate` method now accepts
``None`` as its first argument. (Fixed by Georg Brandl;
:issue:`4759`.)
@@ -315,6 +354,15 @@ Some smaller changes made to the core Python language are:
supported. (Contributed by Alexander Belchenko and Amaury Forgeot
d'Arc; :issue:`1616979`.)
+* The :class:`file` object will now set the :attr:`filename` attribute
+ on the :exc:`IOError` exception when trying to open a directory
+ on POSIX platforms. (Noted by Jan Kaliszewski; :issue:`4764`.)
+
+* Extra parentheses in function definitions are illegal in Python 3.x,
+ meaning that you get a syntax error from ``def f((x)): pass``. In
+ Python3-warning mode, Python 2.7 will now warn about this odd usage.
+ (Noted by James Lingard; :issue:`7362`.)
+
.. ======================================================================
@@ -333,16 +381,16 @@ Several performance enhancements have been added:
:keyword:`with` statements, looking up the :meth:`__enter__` and
:meth:`__exit__` methods. (Contributed by Benjamin Peterson.)
-* The garbage collector now performs better when many objects are
- being allocated without deallocating any. A full garbage collection
- pass is only performed when the middle generation has been collected
- 10 times and when the number of survivor objects from the middle
- generation exceeds 10% of the number of objects in the oldest
- generation. The second condition was added to reduce the number
- of full garbage collections as the number of objects on the heap grows,
- avoiding quadratic performance when allocating very many objects.
- (Suggested by Martin von Loewis and implemented by Antoine Pitrou;
- :issue:`4074`.)
+* The garbage collector now performs better for one common usage
+ pattern: when many objects are being allocated without deallocating
+ any of them. This would previously take quadratic
+ time for garbage collection, but now the number of full garbage collections
+ is reduced as the number of objects on the heap grows.
+ The new logic is to only perform a full garbage collection pass when
+ the middle generation has been collected 10 times and when the
+ number of survivor objects from the middle generation exceeds 10% of
+ the number of objects in the oldest generation. (Suggested by Martin
+ von Loewis and implemented by Antoine Pitrou; :issue:`4074`.)
* The garbage collector tries to avoid tracking simple containers
which can't be part of a cycle. In Python 2.7, this is now true for
@@ -410,7 +458,6 @@ Several performance enhancements have been added:
conversion function that supports arbitrary bases.
(Patch by Gawain Bolton; :issue:`6713`.)
-
.. ======================================================================
New and Improved Modules
@@ -488,12 +535,22 @@ changes, or look through the Subversion logs for all the details.
(Added by Raymond Hettinger; :issue:`1818`.)
The :class:`deque` data type now exposes its maximum length as the
- read-only :attr:`maxlen` attribute. (Added by Raymond Hettinger.)
+ read-only :attr:`maxlen` attribute, and has a
+ :meth:`reverse` method that reverses the elements of the deque in-place.
+ (Added by Raymond Hettinger.)
+
+* The :mod:`copy` module's :func:`deepcopy` function will now
+ correctly copy bound instance methods. (Implemented by
+ Robert Collins; :issue:`1515`.)
* The :mod:`ctypes` module now always converts ``None`` to a C NULL
pointer for arguments declared as pointers. (Changed by Thomas
Heller; :issue:`4606`.)
+* New method: the :mod:`datetime` module's :class:`timedelta` class
+ gained a :meth:`total_seconds` method that returns the number of seconds
+ in the duration. (Contributed by Brian Quinlan; :issue:`5788`.)
+
* New method: the :class:`Decimal` class gained a
:meth:`from_float` class method that performs an exact conversion
of a floating-point number to a :class:`Decimal`.
@@ -539,14 +596,24 @@ changes, or look through the Subversion logs for all the details.
process, but instead simply not install the failing extension.
(Contributed by Georg Brandl; :issue:`5583`.)
- Issue #7457: added a read_pkg_file method to.distutils.dist.DistributionMetadata
- see file:///MacDev/svn.python.org/python-trunk/Doc/build/html/distutils/examples.html#reading-the-metadata
- (:issue:`7457`, added by Tarek).
+ The :class:`distutils.dist.DistributionMetadata` class'
+ :meth:`read_pkg_file` method will read the contents of a package's
+ :file:`PKG-INFO` metadata file. For an example of its use,
+ XXX link to file:///MacDev/svn.python.org/python-trunk/Doc/build/html/distutils/examples.html#reading-the-metadata
+ (Contributed by Tarek Ziade; :issue:`7457`.)
* The :class:`Fraction` class now accepts two rational numbers
as arguments to its constructor.
(Implemented by Mark Dickinson; :issue:`5812`.)
+* The :mod:`ftplib` module gained the ability to establish secure FTP
+ connections using TLS encapsulation of authentication as well as
+ subsequent control and data transfers. This is provided by the new
+ :class:`ftplib.FTP_TLS` class.
+ (Contributed by Giampaolo Rodola', :issue:`2054`.) The :meth:`storbinary`
+ method for binary uploads can now restart uploads thanks to an added
+ *rest* parameter (patch by Pablo Mouzo; :issue:`6845`.)
+
* New function: the :mod:`gc` module's :func:`is_tracked` returns
true if a given instance is tracked by the garbage collector, false
otherwise. (Contributed by Antoine Pitrou; :issue:`4688`.)
@@ -627,8 +694,12 @@ changes, or look through the Subversion logs for all the details.
with any object literal that decodes to a list of pairs.
(Contributed by Raymond Hettinger; :issue:`5381`.)
-* New functions: the :mod:`math` module now has
- a :func:`gamma` function.
+* New functions: the :mod:`math` module gained
+ :func:`erf` and :func:`erfc` for the error function and the complementary error function,
+ :func:`expm1` which computes ``e**x - 1`` with more precision than
+ using :func:`exp` and subtracting 1,
+ :func:`gamma` for the Gamma function, and
+ :func:`lgamma` for the natural log of the Gamma function.
(Contributed by Mark Dickinson and nirinA raseliarison; :issue:`3366`.)
* The :mod:`multiprocessing` module's :class:`Manager*` classes
@@ -640,6 +711,15 @@ changes, or look through the Subversion logs for all the details.
* The :mod:`nntplib` module now supports IPv6 addresses.
(Contributed by Derek Morr; :issue:`1664`.)
+* New functions: the :mod:`os` module wraps the following POSIX system
+ calls: :func:`getresgid` and :func:`getresuid`, which return the
+ real, effective, and saved GIDs and UIDs;
+ :func:`setresgid` and :func:`setresuid`, which set
+ real, effective, and saved GIDs and UIDs to new values;
+ :func:`initgroups`. (GID/UID functions
+ contributed by Travis H.; :issue:`6508`. Support for initgroups added
+ by Jean-Paul Calderone; :issue:`7333`.)
+
* The :mod:`pydoc` module now has help for the various symbols that Python
uses. You can now do ``help('<<')`` or ``help('@')``, for example.
(Contributed by David Laban; :issue:`4739`.)
@@ -728,12 +808,6 @@ changes, or look through the Subversion logs for all the details.
:mod:`zipfile` now supports archiving empty directories and
extracts them correctly. (Fixed by Kuba Wieczorek; :issue:`4710`.)
-* The :mod:`ftplib` module gains the ability to establish secure FTP
- connections using TLS encapsulation of authentication as well as
- subsequent control and data transfers. This is provided by the new
- :class:`ftplib.FTP_TLS` class.
- (Contributed by Giampaolo Rodola', :issue:`2054`.)
-
.. ======================================================================
.. whole new modules get described in subsections here
@@ -855,7 +929,7 @@ importlib: Importing Modules
Python 3.1 includes the :mod:`importlib` package, a re-implementation
of the logic underlying Python's :keyword:`import` statement.
:mod:`importlib` is useful for implementors of Python interpreters and
-to user who wish to write new importers that can participate in the
+to users who wish to write new importers that can participate in the
import process. Python 2.7 doesn't contain the complete
:mod:`importlib` package, but instead has a tiny subset that contains
a single function, :func:`import_module`.
@@ -934,12 +1008,23 @@ Changes to Python's build process and to the C API include:
extensions needed to call :cfunc:`PyCode_New`, which had many
more arguments. (Added by Jeffrey Yasskin.)
+* New function: :cfunc:`PyErr_NewExceptionWithDoc` creates a new
+ exception class, just as the existing :cfunc:`PyErr_NewException` does,
+ but takes an extra ``char *`` argument containing the docstring for the
+ new exception class. (Added by the 'lekma' user on the Python bug tracker;
+ :issue:`7033`.)
+
* New function: :cfunc:`PyFrame_GetLineNumber` takes a frame object
and returns the line number that the frame is currently executing.
Previously code would need to get the index of the bytecode
instruction currently executing, and then look up the line number
corresponding to that address. (Added by Jeffrey Yasskin.)
+* New function: :cfunc:`PyLong_AsLongAndOverflow` approximates a Python long
+ integer as a C :ctype:`long`. If the number is too large to fit into
+ a :ctype:`long`, an *overflow* flag is set and returned to the caller.
+ (Contributed by Case Van Horsen; :issue:`7528`.)
+
* New macros: the Python header files now define the following macros:
:cmacro:`Py_ISALNUM`,
:cmacro:`Py_ISALPHA`,
@@ -958,6 +1043,12 @@ Changes to Python's build process and to the C API include:
.. XXX these macros don't seem to be described in the c-api docs.
+* New format codes: the :cfunc:`PyFormat_FromString`,
+ :cfunc:`PyFormat_FromStringV`, and :cfunc:`PyErr_Format` now
+ accepts ``%lld`` and ``%llu`` format codes for displaying values of
+ C's :ctype:`long long` types.
+ (Contributed by Mark Dickinson; :issue:`7228`.)
+
* The complicated interaction between threads and process forking has
been changed. Previously, the child process created by
:func:`os.fork` might fail because the child is created with only a
@@ -992,6 +1083,12 @@ Changes to Python's build process and to the C API include:
* The build process now supports Subversion 1.7. (Contributed by
Arfrever Frehtes Taifersar Arahesis; :issue:`6094`.)
+* Compiling Python with the :option:`--with-valgrind` option will now
+ disable the pymalloc allocator, which is difficult for the Valgrind to
+ analyze correctly. Valgrind will therefore be better at detecting
+ memory leaks and overruns. (Contributed by James Henstridge; :issue:`2422`.)
+
+
.. ======================================================================
Port-Specific Changes: Windows
@@ -1011,6 +1108,10 @@ Port-Specific Changes: Windows
* The :func:`os.listdir` function now correctly fails
for an empty path. (Fixed by Hirokazu Yamamoto; :issue:`5913`.)
+* The :mod:`mimelib` module will now read the MIME database from
+ the Windows registry when initializing.
+ (Patch by Gabriel Genellina; :issue:`4969`.)
+
.. ======================================================================
Port-Specific Changes: Mac OS X
@@ -1070,6 +1171,10 @@ that may require changes to your code:
affects new-style classes (derived from :class:`object`) and C extension
types. (:issue:`6101`.)
+* The :meth:`readline` method of :class:`StringIO` objects now does
+ nothing when a negative length is requested, as other file-like
+ objects do. (:issue:`7348`).
+
.. ======================================================================