This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import combinations | |
from typing import List | |
def subsets(the_dict: dict) -> List[dict]: | |
subsets_as_tuples = [] | |
dict_as_tuple = the_dict.items() | |
# We start from 1 in the range since list(combinations(some_dict, 0)) returns an empty list | |
for i in range(1, len(the_dict) + 1): | |
subsets_as_tuples.extend(list(combinations(dict_as_tuple, i))) | |
print(subsets_as_tuples) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python -m timeit -s "from defaultdict_salary_technique import highest_paid_employees" "highest_paid_employees()" | |
100000 loops, best of 5: 2.5 usec per loop | |
python -m memory_profiler defaultdict_salary_technique.py | |
Filename: defaultdict_salary_technique.py | |
Line # Mem usage Increment Occurences Line Contents | |
============================================================ | |
10 37.953 MiB 37.953 MiB 1 @profile |