code: def quick_ratio(self):
          
  
          # viewing a and b as multisets, set matches to the cardinality
          # of their intersection; this counts the number of matches
          # without regard to order, so is clearly an upper bound
          if self.fullbcount is None:
              self.fullbcount = fullbcount = {}
              for elt in self.b:
                  fullbcount[elt] = fullbcount.get(elt, 0) + 1
          fullbcount = self.fullbcount
          # avail[x] is the number of times x appears in 'b' less the
          # number of times we've seen it in 'a' so far ... kinda
          avail = {}
          availhas, matches = avail.__contains__, 0
          for elt in self.a:
              if availhas(elt):
                  numb = avail[elt]
              else:
                  numb = fullbcount.get(elt, 0)
              avail[elt] = numb - 1
              if numb > 0:
                  matches = matches + 1
          return _calculate_ratio(matches, len(self.a) + len(self.b))
docs: Return an upper bound on ratio() relatively quickly.
  
          This isn't defined beyond that it is an upper bound on .ratio(), and
          is faster to compute.