Path 1: 719 calls (0.97)

{} (719)

1def remove_successive(all_couples: CplIndexToCplLines_T) -> None:
2    """Removes all successive entries in the dictionary in argument.
3
4    :param all_couples: collection that has to be cleaned up from successive entries.
5                        The keys are couples of indices that mark the beginning of common entries
6                        in both linesets. The values have two parts. The first one is the couple
7                        of starting and ending line numbers of common successive lines in the first file.
8                        The second part is the same for the second file.
9
10    For example consider the following dict:
11
12    >>> all_couples
13    {(11, 34): ([5, 9], [27, 31]),
14     (23, 79): ([15, 19], [45, 49]),
15     (12, 35): ([6, 10], [28, 32])}
16
17    There are two successive keys (11, 34) and (12, 35).
18    It means there are two consecutive similar chunks of lines in both files.
19    Thus remove last entry and update the last line numbers in the first entry
20
21    >>> remove_successive(all_couples)
22    >>> all_couples
23    {(11, 34): ([5, 10], [27, 32]),
24     (23, 79): ([15, 19], [45, 49])}
25    """
26    couple: LineSetStartCouple
27    for couple in tuple(all_couples.keys()):
28        to_remove = []
29        test = couple.increment(Index(1))
30        while test in all_couples:
31            all_couples[couple].first_file.end = all_couples[test].first_file.end
32            all_couples[couple].second_file.end = all_couples[test].second_file.end
33            all_couples[couple].effective_cmn_lines_nb += 1
34            to_remove.append(test)
35            test = test.increment(Index(1))
36
37        for target in to_remove:
38            try:
39                all_couples.pop(target)
40            except KeyError:
41                pass
            

Path 2: 19 calls (0.03)

dict (19)

1def remove_successive(all_couples: CplIndexToCplLines_T) -> None:
2    """Removes all successive entries in the dictionary in argument.
3
4    :param all_couples: collection that has to be cleaned up from successive entries.
5                        The keys are couples of indices that mark the beginning of common entries
6                        in both linesets. The values have two parts. The first one is the couple
7                        of starting and ending line numbers of common successive lines in the first file.
8                        The second part is the same for the second file.
9
10    For example consider the following dict:
11
12    >>> all_couples
13    {(11, 34): ([5, 9], [27, 31]),
14     (23, 79): ([15, 19], [45, 49]),
15     (12, 35): ([6, 10], [28, 32])}
16
17    There are two successive keys (11, 34) and (12, 35).
18    It means there are two consecutive similar chunks of lines in both files.
19    Thus remove last entry and update the last line numbers in the first entry
20
21    >>> remove_successive(all_couples)
22    >>> all_couples
23    {(11, 34): ([5, 10], [27, 32]),
24     (23, 79): ([15, 19], [45, 49])}
25    """
26    couple: LineSetStartCouple
27    for couple in tuple(all_couples.keys()):
28        to_remove = []
29        test = couple.increment(Index(1))
30        while test in all_couples:
31            all_couples[couple].first_file.end = all_couples[test].first_file.end
32            all_couples[couple].second_file.end = all_couples[test].second_file.end
33            all_couples[couple].effective_cmn_lines_nb += 1
34            to_remove.append(test)
35            test = test.increment(Index(1))
36
37        for target in to_remove:
38            try:
39                all_couples.pop(target)
40            except KeyError:
41                pass
            

Path 3: 2 calls (0.0)

dict (2)

1def remove_successive(all_couples: CplIndexToCplLines_T) -> None:
2    """Removes all successive entries in the dictionary in argument.
3
4    :param all_couples: collection that has to be cleaned up from successive entries.
5                        The keys are couples of indices that mark the beginning of common entries
6                        in both linesets. The values have two parts. The first one is the couple
7                        of starting and ending line numbers of common successive lines in the first file.
8                        The second part is the same for the second file.
9
10    For example consider the following dict:
11
12    >>> all_couples
13    {(11, 34): ([5, 9], [27, 31]),
14     (23, 79): ([15, 19], [45, 49]),
15     (12, 35): ([6, 10], [28, 32])}
16
17    There are two successive keys (11, 34) and (12, 35).
18    It means there are two consecutive similar chunks of lines in both files.
19    Thus remove last entry and update the last line numbers in the first entry
20
21    >>> remove_successive(all_couples)
22    >>> all_couples
23    {(11, 34): ([5, 10], [27, 32]),
24     (23, 79): ([15, 19], [45, 49])}
25    """
26    couple: LineSetStartCouple
27    for couple in tuple(all_couples.keys()):
28        to_remove = []
29        test = couple.increment(Index(1))
30        while test in all_couples:
31            all_couples[couple].first_file.end = all_couples[test].first_file.end
32            all_couples[couple].second_file.end = all_couples[test].second_file.end
33            all_couples[couple].effective_cmn_lines_nb += 1
34            to_remove.append(test)
35            test = test.increment(Index(1))
36
37        for target in to_remove:
38            try:
39                all_couples.pop(target)
40            except KeyError:
41                pass