mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
Removed Exact/Inexact after discussion with Yasskin.
Unlike Scheme where exactness is implemented as taints, the Python implementation associated exactness with data types. This created inheritance issues (making an exact subclass of floats would result in the subclass having both an explicit Exact registration and an inherited Inexact registration). This was a problem for the decimal module which was designed to span both exact and inexact arithmetic. There was also a question of use cases and no examples were found where ABCs for exactness could be used to improve code. One other issue was having separate tags for both the affirmative and negative cases. This is at odds with the approach taken elsewhere in the Python (i.e. we don't have an ABC both Hashable and Unhashable).
This commit is contained in:
parent
32ed8c267c
commit
6b46762974
2 changed files with 4 additions and 63 deletions
|
|
@ -4,7 +4,6 @@ import math
|
|||
import operator
|
||||
import unittest
|
||||
from numbers import Complex, Real, Rational, Integral
|
||||
from numbers import Exact, Inexact
|
||||
from numbers import Number
|
||||
from test import test_support
|
||||
|
||||
|
|
@ -12,8 +11,6 @@ class TestNumbers(unittest.TestCase):
|
|||
def test_int(self):
|
||||
self.failUnless(issubclass(int, Integral))
|
||||
self.failUnless(issubclass(int, Complex))
|
||||
self.failUnless(issubclass(int, Exact))
|
||||
self.failIf(issubclass(int, Inexact))
|
||||
|
||||
self.assertEqual(7, int(7).real)
|
||||
self.assertEqual(0, int(7).imag)
|
||||
|
|
@ -24,8 +21,6 @@ class TestNumbers(unittest.TestCase):
|
|||
def test_long(self):
|
||||
self.failUnless(issubclass(long, Integral))
|
||||
self.failUnless(issubclass(long, Complex))
|
||||
self.failUnless(issubclass(long, Exact))
|
||||
self.failIf(issubclass(long, Inexact))
|
||||
|
||||
self.assertEqual(7, long(7).real)
|
||||
self.assertEqual(0, long(7).imag)
|
||||
|
|
@ -36,8 +31,6 @@ class TestNumbers(unittest.TestCase):
|
|||
def test_float(self):
|
||||
self.failIf(issubclass(float, Rational))
|
||||
self.failUnless(issubclass(float, Real))
|
||||
self.failIf(issubclass(float, Exact))
|
||||
self.failUnless(issubclass(float, Inexact))
|
||||
|
||||
self.assertEqual(7.3, float(7.3).real)
|
||||
self.assertEqual(0, float(7.3).imag)
|
||||
|
|
@ -46,8 +39,6 @@ class TestNumbers(unittest.TestCase):
|
|||
def test_complex(self):
|
||||
self.failIf(issubclass(complex, Real))
|
||||
self.failUnless(issubclass(complex, Complex))
|
||||
self.failIf(issubclass(complex, Exact))
|
||||
self.failUnless(issubclass(complex, Inexact))
|
||||
|
||||
c1, c2 = complex(3, 2), complex(4,1)
|
||||
# XXX: This is not ideal, but see the comment in math_trunc().
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue