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 # 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 @abstractmethod
def __float__(self): 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, If ndigits is omitted or None, returns an Integral,
otherwise returns a Real, preferably of the same type as otherwise returns a Real, preferably of the same type as
self. Types may choose which direction to round half. For self. Types may choose which direction to round half. For
example, float rounds half toward even, and Decimal rounds example, float rounds half toward even.
it according to the current context.
""" """
raise NotImplementedError raise NotImplementedError
@ -319,7 +318,7 @@ And finally integers::
raise NotImplementedError raise NotImplementedError
def __index__(self): def __index__(self):
"""__index__() exists because float and Decimal have __int__().""" """__index__() exists because float has __int__()."""
return int(self) return int(self)
@abstractmethod @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 In 2.6, ``math.floor``, ``math.ceil``, and ``round`` will continue to
return floats. return floats.
Because the ``int()`` conversion implemented by ``float`` (and by The ``int()`` conversion implemented by ``float`` is equivalent to
``decimal.Decimal``) is equivalent to but less explicit than ``trunc()``. In general, the ``int()`` conversion should try
``trunc()``, let's remove it. (Or, if that breaks too much, just add a ``__int__()`` first and if it is not found, try ``__trunc__()``.
deprecation warning.)
``complex.__{divmod,mod,floordiv,int,float}__`` also go away. It would ``complex.__{divmod,mod,floordiv,int,float}__`` also go away. It would
be nice to provide a nice error message to help confused porters, but 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. 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 References
========== ==========