MCPcopy Index your code
hub / github.com/RustPython/RustPython / compare

Method compare

Lib/_pydecimal.py:876–892  ·  view source on GitHub ↗

Compare self to other. Return a decimal value: a or b is a NaN ==> Decimal('NaN') a < b ==> Decimal('-1') a == b ==> Decimal('0') a > b ==> Decimal('1')

(self, other, context=None)

Source from the content-addressed store, hash-verified

874 return self._cmp(other) >= 0
875
876 def compare(self, other, context=None):
877 """Compare self to other. Return a decimal value:
878
879 a or b is a NaN ==> Decimal('NaN')
880 a < b ==> Decimal('-1')
881 a == b ==> Decimal('0')
882 a > b ==> Decimal('1')
883 """
884 other = _convert_other(other, raiseit=True)
885
886 # Compare(NaN, NaN) = NaN
887 if (self._is_special or other and other._is_special):
888 ans = self._check_nans(other, context)
889 if ans:
890 return ans
891
892 return Decimal(self._cmp(other))
893
894 def __hash__(self):
895 """x.__hash__() <==> hash(x)"""

Callers 3

compare_signalMethod · 0.95
test_none_argsMethod · 0.95
compareMethod · 0.45

Calls 4

_check_nansMethod · 0.95
_cmpMethod · 0.95
_convert_otherFunction · 0.85
DecimalClass · 0.85

Tested by 1

test_none_argsMethod · 0.76