mirror of
https://github.com/python/cpython.git
synced 2025-08-27 20:25:18 +00:00
Issue #8188: Introduce a new scheme for computing hashes of numbers
(instances of int, float, complex, decimal.Decimal and fractions.Fraction) that makes it easy to maintain the invariant that hash(x) == hash(y) whenever x and y have equal value.
This commit is contained in:
parent
03721133a6
commit
dc787d2055
14 changed files with 566 additions and 137 deletions
|
@ -914,15 +914,6 @@ class InfNanTest(unittest.TestCase):
|
|||
self.assertFalse(NAN.is_inf())
|
||||
self.assertFalse((0.).is_inf())
|
||||
|
||||
def test_hash_inf(self):
|
||||
# the actual values here should be regarded as an
|
||||
# implementation detail, but they need to be
|
||||
# identical to those used in the Decimal module.
|
||||
self.assertEqual(hash(float('inf')), 314159)
|
||||
self.assertEqual(hash(float('-inf')), -271828)
|
||||
self.assertEqual(hash(float('nan')), 0)
|
||||
|
||||
|
||||
fromHex = float.fromhex
|
||||
toHex = float.hex
|
||||
class HexFloatTestCase(unittest.TestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue