Explicitly acknowledge that Decimal will not become part of the numeric tower.

This commit is contained in:
Guido van Rossum 2008-02-10 01:14:46 +00:00
parent 67bf7b0e45
commit e7562c1707
1 changed files with 14 additions and 8 deletions

View File

@ -171,7 +171,7 @@ totally ordered except for NaNs (which this PEP basically ignores). ::
"""
# XXX What to do about the __int__ implementation that's
# currently present on float and Decimal? Get rid of it?
# currently present on float? Get rid of it?
@abstractmethod
def __float__(self):
@ -208,8 +208,7 @@ totally ordered except for NaNs (which this PEP basically ignores). ::
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.
example, float rounds half toward even.
"""
raise NotImplementedError
@ -319,7 +318,7 @@ And finally integers::
raise NotImplementedError
def __index__(self):
"""__index__() exists because float and Decimal have __int__()."""
"""__index__() exists because float has __int__()."""
return int(self)
@abstractmethod
@ -440,10 +439,9 @@ functions. All of these return Integrals rather than Reals.
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
``trunc()``, let's remove it. (Or, if that breaks too much, just add a
deprecation warning.)
The ``int()`` conversion implemented by ``float`` is equivalent to
``trunc()``. In general, the ``int()`` conversion should try
``__int__()`` first and if it is not found, try ``__trunc__()``.
``complex.__{divmod,mod,floordiv,int,float}__`` also go away. It would
be nice to provide a nice error message to help confused porters, but
@ -554,6 +552,14 @@ scaled back the proposal to resemble the Scheme numeric tower much
more closely.
The Decimal Type
================
After consultation with its authors it has been decided that the
``Decimal`` type should not at this time be made part of the numeric
tower.
References
==========