class_docstr: This class implements rational numbers.
  
  In the two-argument form of the constructor, Fraction(8, 6) will
  produce a rational number equivalent to 4/3. Both arguments must
  be Rational. The numerator defaults to 0 and the denominator
  defaults to 1 so that Fraction(3) == 3 and Fraction() == 0.
  
  Fractions can also be constructed from:
  
    - numeric strings similar to those accepted by the
      float constructor (for example, '-2.3' or '1e10')
  
    - strings of the form '123/456'
  
    - float and Decimal instances
  
    - other Rational instances (including integers)
class_docstr_tok: ["This","class","implements","rational","numbers",".","In","the","two-argument","form","of","the","constructor",",","Fraction","(","8",",","6",")","will","produce","a","rational","number","equivalent","to","4\/3",".","Both","arguments","must","be","Rational",".","The","numerator","defaults","to","0","and","the","denominator","defaults","to","1","so","that","Fraction","(","3",")","==","3","and","Fraction","(",")","==","0",".","Fractions","can","also","be","constructed","from",":","-","numeric","strings","similar","to","those","accepted","by","the","float","constructor","(","for","example",",","'-2.3","'","or","'1e10","'",")","-","strings","of","the","form","'123\/456'","-","float","and","Decimal","instances","-","other","Rational","instances","(","including","integers",")"]
docstr: hash(self)
docstr_tok: ["hash","(","self",")"]
code: def __hash__(self):
      """hash(self)"""
  
      # To make sure that the hash of a Fraction agrees with the hash
      # of a numerically equal integer, float or Decimal instance, we
      # follow the rules for numeric hashes outlined in the
      # documentation.  (See library docs, 'Built-in Types').
  
      try:
          dinv = pow(self._denominator, -1, _PyHASH_MODULUS)
      except ValueError:
          # ValueError means there is no modular inverse.
          hash_ = _PyHASH_INF
      else:
          # The general algorithm now specifies that the absolute value of
          # the hash is
          #    (|N| * dinv) % P
          # where N is self._numerator and P is _PyHASH_MODULUS.  That's
          # optimized here in two ways:  first, for a non-negative int i,
          # hash(i) == i % P, but the int hash implementation doesn't need
          # to divide, and is faster than doing % P explicitly.  So we do
          #    hash(|N| * dinv)
          # instead.  Second, N is unbounded, so its product with dinv may
          # be arbitrarily expensive to compute.  The final answer is the
          # same if we use the bounded |N| % P instead, which can again
          # be done with an int hash() call.  If 0 <= i < P, hash(i) == i,
          # so this nested hash() call wastes a bit of time making a
          # redundant copy when |N| < P, but can save an arbitrarily large
          # amount of computation for large |N|.
          hash_ = hash(hash(abs(self._numerator)) * dinv)
      result = hash_ if self._numerator >= 0 else -hash_
      return -2 if result == -1 else result
  
imports: from decimal import Decimal
  import math
  import numbers
  import operator
  import re
  import sys
label_desc: Use image node_id 28 for calling the Fraction obj's underlying member method code with example usage: obj.__hash__() and returns: unknown