[Python-checkins] r59805 - peps/trunk/pep-3141.txt
jeffrey.yasskin
python-checkins at python.org
Mon Jan 7 01:25:38 CET 2008
Author: jeffrey.yasskin
Date: Mon Jan 7 01:25:37 2008
New Revision: 59805
Modified:
peps/trunk/pep-3141.txt
Log:
Update PEP 3141 according to the conclusion of
http://mail.python.org/pipermail/python-dev/2008-January/075921.html. Different
types may have different rounding behavior, but float will definitely
round-to-even.
Modified: peps/trunk/pep-3141.txt
==============================================================================
--- peps/trunk/pep-3141.txt (original)
+++ peps/trunk/pep-3141.txt Mon Jan 7 01:25:37 2008
@@ -205,8 +205,12 @@
def __round__(self, ndigits:Integral=None):
"""Rounds self to ndigits decimal places, defaulting to 0.
- If ndigits is omitted or None, returns an Integral, otherwise
- returns a Real. Rounds half toward even.
+ If ndigits is omitted or None, returns an Integral,
+ otherwise returns a Real, preferably of the same type as
+ self. Types may choose which direction to round half. For
+ example, float rounds half toward even, and Decimal rounds
+ it according to the current context.
+
"""
raise NotImplementedError
@@ -428,9 +432,13 @@
least Integral ``>= x``.
4. ``__round__(self)``, called from ``round(x)``, which returns the
- Integral closest to ``x``, rounding half toward even. There is also
- a 2-argument version, ``__round__(self, other)``, called from
- ``round(x, y)``, which should return a Real.
+ Integral closest to ``x``, rounding half as the type chooses.
+ ``float`` will change in 3.0 to round half toward even. There is
+ also a 2-argument version, ``__round__(self, ndigits)``, called
+ from ``round(x, ndigits)``, which should return a Real.
+
+In 2.6, ``math.floor``, ``math.ceil``, and ``round`` will continue to
+return floats.
Because the ``int()`` conversion implemented by ``float`` (and by
``decimal.Decimal``) is equivalent to but less explicit than
More information about the Python-checkins
mailing list