Method: difflib.SequenceMatcher.quick_ratio
Calls: 514, Exceptions: 0, Paths: 9Back
Path 1: 234 calls (0.46)
0.6933333333333334 (36) 1.0 (19) 0.7222222222222222 (18) 0.7792207792207793 (18) 0.972972972972973 (18) 0.8125 (15) 0.875 (9) 0.18181818181818182 (8) ...
1def quick_ratio(self):
2 """Return an upper bound on ratio() relatively quickly.
3
4 This isn't defined beyond that it is an upper bound on .ratio(), and
5 is faster to compute.
6 """
7
8 # viewing a and b as multisets, set matches to the cardinality
9 # of their intersection; this counts the number of matches
10 # without regard to order, so is clearly an upper bound
11 if self.fullbcount is None:
12 self.fullbcount = fullbcount = {}
13 for elt in self.b:
14 fullbcount[elt] = fullbcount.get(elt, 0) + 1
15 fullbcount = self.fullbcount
16 # avail[x] is the number of times x appears in 'b' less the
17 # number of times we've seen it in 'a' so far ... kinda
18 avail = {}
19 availhas, matches = avail.__contains__, 0
20 for elt in self.a:
21 if availhas(elt):
22 numb = avail[elt]
23 else:
24 numb = fullbcount.get(elt, 0)
25 avail[elt] = numb - 1
26 if numb > 0:
27 matches = matches + 1
28 return _calculate_ratio(matches, len(self.a) + len(self.b))
Path 2: 164 calls (0.32)
0.9444444444444444 (34) 0.8 (22) 0.7567567567567568 (19) 1.0 (18) 0.6756756756756757 (17) 0.875 (9) 0.8125 (9) 0.9069767441860465 (4) 0.79591836734693...
1def quick_ratio(self):
2 """Return an upper bound on ratio() relatively quickly.
3
4 This isn't defined beyond that it is an upper bound on .ratio(), and
5 is faster to compute.
6 """
7
8 # viewing a and b as multisets, set matches to the cardinality
9 # of their intersection; this counts the number of matches
10 # without regard to order, so is clearly an upper bound
11 if self.fullbcount is None:
12 self.fullbcount = fullbcount = {}
13 for elt in self.b:
14 fullbcount[elt] = fullbcount.get(elt, 0) + 1
15 fullbcount = self.fullbcount
16 # avail[x] is the number of times x appears in 'b' less the
17 # number of times we've seen it in 'a' so far ... kinda
18 avail = {}
19 availhas, matches = avail.__contains__, 0
20 for elt in self.a:
21 if availhas(elt):
22 numb = avail[elt]
23 else:
24 numb = fullbcount.get(elt, 0)
25 avail[elt] = numb - 1
26 if numb > 0:
27 matches = matches + 1
28 return _calculate_ratio(matches, len(self.a) + len(self.b))
Path 3: 48 calls (0.09)
0.2222222222222222 (9) 0.5 (8) 0.2 (8) 0.4444444444444444 (6) 0.25 (5) 0.4 (3) 0.18181818181818182 (3) 0.36363636363636365 (3) 0.6 (1) 0.8 (1)
1def quick_ratio(self):
2 """Return an upper bound on ratio() relatively quickly.
3
4 This isn't defined beyond that it is an upper bound on .ratio(), and
5 is faster to compute.
6 """
7
8 # viewing a and b as multisets, set matches to the cardinality
9 # of their intersection; this counts the number of matches
10 # without regard to order, so is clearly an upper bound
11 if self.fullbcount is None:
12 self.fullbcount = fullbcount = {}
13 for elt in self.b:
14 fullbcount[elt] = fullbcount.get(elt, 0) + 1
15 fullbcount = self.fullbcount
16 # avail[x] is the number of times x appears in 'b' less the
17 # number of times we've seen it in 'a' so far ... kinda
18 avail = {}
19 availhas, matches = avail.__contains__, 0
20 for elt in self.a:
21 if availhas(elt):
22 numb = avail[elt]
23 else:
24 numb = fullbcount.get(elt, 0)
25 avail[elt] = numb - 1
26 if numb > 0:
27 matches = matches + 1
28 return _calculate_ratio(matches, len(self.a) + len(self.b))
Path 4: 24 calls (0.05)
0.75 (8) 0.4166666666666667 (6) 0.4444444444444444 (3) 0.5 (3) 0.4 (2) 0.7692307692307693 (1) 0.36363636363636365 (1)
1def quick_ratio(self):
2 """Return an upper bound on ratio() relatively quickly.
3
4 This isn't defined beyond that it is an upper bound on .ratio(), and
5 is faster to compute.
6 """
7
8 # viewing a and b as multisets, set matches to the cardinality
9 # of their intersection; this counts the number of matches
10 # without regard to order, so is clearly an upper bound
11 if self.fullbcount is None:
12 self.fullbcount = fullbcount = {}
13 for elt in self.b:
14 fullbcount[elt] = fullbcount.get(elt, 0) + 1
15 fullbcount = self.fullbcount
16 # avail[x] is the number of times x appears in 'b' less the
17 # number of times we've seen it in 'a' so far ... kinda
18 avail = {}
19 availhas, matches = avail.__contains__, 0
20 for elt in self.a:
21 if availhas(elt):
22 numb = avail[elt]
23 else:
24 numb = fullbcount.get(elt, 0)
25 avail[elt] = numb - 1
26 if numb > 0:
27 matches = matches + 1
28 return _calculate_ratio(matches, len(self.a) + len(self.b))
Path 5: 16 calls (0.03)
0.0 (16)
1def quick_ratio(self):
2 """Return an upper bound on ratio() relatively quickly.
3
4 This isn't defined beyond that it is an upper bound on .ratio(), and
5 is faster to compute.
6 """
7
8 # viewing a and b as multisets, set matches to the cardinality
9 # of their intersection; this counts the number of matches
10 # without regard to order, so is clearly an upper bound
11 if self.fullbcount is None:
12 self.fullbcount = fullbcount = {}
13 for elt in self.b:
14 fullbcount[elt] = fullbcount.get(elt, 0) + 1
15 fullbcount = self.fullbcount
16 # avail[x] is the number of times x appears in 'b' less the
17 # number of times we've seen it in 'a' so far ... kinda
18 avail = {}
19 availhas, matches = avail.__contains__, 0
20 for elt in self.a:
21 if availhas(elt):
22 numb = avail[elt]
23 else:
24 numb = fullbcount.get(elt, 0)
25 avail[elt] = numb - 1
26 if numb > 0:
27 matches = matches + 1
28 return _calculate_ratio(matches, len(self.a) + len(self.b))
Path 6: 10 calls (0.02)
0.0 (10)
1def quick_ratio(self):
2 """Return an upper bound on ratio() relatively quickly.
3
4 This isn't defined beyond that it is an upper bound on .ratio(), and
5 is faster to compute.
6 """
7
8 # viewing a and b as multisets, set matches to the cardinality
9 # of their intersection; this counts the number of matches
10 # without regard to order, so is clearly an upper bound
11 if self.fullbcount is None:
12 self.fullbcount = fullbcount = {}
13 for elt in self.b:
14 fullbcount[elt] = fullbcount.get(elt, 0) + 1
15 fullbcount = self.fullbcount
16 # avail[x] is the number of times x appears in 'b' less the
17 # number of times we've seen it in 'a' so far ... kinda
18 avail = {}
19 availhas, matches = avail.__contains__, 0
20 for elt in self.a:
21 if availhas(elt):
22 numb = avail[elt]
23 else:
24 numb = fullbcount.get(elt, 0)
25 avail[elt] = numb - 1
26 if numb > 0:
27 matches = matches + 1
28 return _calculate_ratio(matches, len(self.a) + len(self.b))
Path 7: 9 calls (0.02)
0.0 (9)
1def quick_ratio(self):
2 """Return an upper bound on ratio() relatively quickly.
3
4 This isn't defined beyond that it is an upper bound on .ratio(), and
5 is faster to compute.
6 """
7
8 # viewing a and b as multisets, set matches to the cardinality
9 # of their intersection; this counts the number of matches
10 # without regard to order, so is clearly an upper bound
11 if self.fullbcount is None:
12 self.fullbcount = fullbcount = {}
13 for elt in self.b:
14 fullbcount[elt] = fullbcount.get(elt, 0) + 1
15 fullbcount = self.fullbcount
16 # avail[x] is the number of times x appears in 'b' less the
17 # number of times we've seen it in 'a' so far ... kinda
18 avail = {}
19 availhas, matches = avail.__contains__, 0
20 for elt in self.a:
21 if availhas(elt):
22 numb = avail[elt]
23 else:
24 numb = fullbcount.get(elt, 0)
25 avail[elt] = numb - 1
26 if numb > 0:
27 matches = matches + 1
28 return _calculate_ratio(matches, len(self.a) + len(self.b))
Path 8: 8 calls (0.02)
0.0 (8)
1def quick_ratio(self):
2 """Return an upper bound on ratio() relatively quickly.
3
4 This isn't defined beyond that it is an upper bound on .ratio(), and
5 is faster to compute.
6 """
7
8 # viewing a and b as multisets, set matches to the cardinality
9 # of their intersection; this counts the number of matches
10 # without regard to order, so is clearly an upper bound
11 if self.fullbcount is None:
12 self.fullbcount = fullbcount = {}
13 for elt in self.b:
14 fullbcount[elt] = fullbcount.get(elt, 0) + 1
15 fullbcount = self.fullbcount
16 # avail[x] is the number of times x appears in 'b' less the
17 # number of times we've seen it in 'a' so far ... kinda
18 avail = {}
19 availhas, matches = avail.__contains__, 0
20 for elt in self.a:
21 if availhas(elt):
22 numb = avail[elt]
23 else:
24 numb = fullbcount.get(elt, 0)
25 avail[elt] = numb - 1
26 if numb > 0:
27 matches = matches + 1
28 return _calculate_ratio(matches, len(self.a) + len(self.b))
Path 9: 1 calls (0.0)
1.0 (1)
1def quick_ratio(self):
2 """Return an upper bound on ratio() relatively quickly.
3
4 This isn't defined beyond that it is an upper bound on .ratio(), and
5 is faster to compute.
6 """
7
8 # viewing a and b as multisets, set matches to the cardinality
9 # of their intersection; this counts the number of matches
10 # without regard to order, so is clearly an upper bound
11 if self.fullbcount is None:
12 self.fullbcount = fullbcount = {}
13 for elt in self.b:
14 fullbcount[elt] = fullbcount.get(elt, 0) + 1
15 fullbcount = self.fullbcount
16 # avail[x] is the number of times x appears in 'b' less the
17 # number of times we've seen it in 'a' so far ... kinda
18 avail = {}
19 availhas, matches = avail.__contains__, 0
20 for elt in self.a:
21 if availhas(elt):
22 numb = avail[elt]
23 else:
24 numb = fullbcount.get(elt, 0)
25 avail[elt] = numb - 1
26 if numb > 0:
27 matches = matches + 1
28 return _calculate_ratio(matches, len(self.a) + len(self.b))