def stringRatio( a, b ):
    """
    Calculates the string ratio of a to b.

    If the strings are equal, returns 1.0.  If they have no similarity
    whatsoever, returns 0.0.  Otherwise, returns a number in-between.
    """

    if a == b:
        return 1.0
    elif a in b:
        return float( len(a) ) / len(b)
    elif b in a:
        return float( len(b) ) / len(a)
    else:
        # The following code is actually identical to this code:
        #
        #  import difflib
        #  seqMatch = difflib.SequenceMatcher( False, a, b )
        #  ratio = seqMatch.real_quick_ratio()
        #  return ratio
        #
        # But has been copied from difflib and pasted inline here for
        # efficiency purposes.
        
        la, lb = len(a), len(b)

        length = la + lb
        if length:
            return 2.0 * (min(la, lb)) / length
        return 1.0