'Returns the cached distance between two vectors.'

def distance(self, v1, v2):

    try:
        d = self._cache[(v1.id, v2.id)]
    except KeyError:
        d = self._cache[(v1.id, v2.id)] = distance(v1, v2, method=self.method)
    except AttributeError:
        d = distance(v1, v2, method=self.method)
    return d
