Skip to content

Commit 354cd4f

Browse files
committed
fixing more linter issues
1 parent 4df8503 commit 354cd4f

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

sort-python-dictionary/compare_lookup_dict_vs_list.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
from timeit import timeit
2-
from samples import dictionary_of_dictionaries, list_of_dictionaries
32

43
lookups = [15, 18, 19, 16, 6, 12, 5, 3, 9, 20, 2, 10, 13, 17, 4, 14, 11, 7, 8]
54

65
list_setup = """
6+
from samples import list_of_dictionaries
7+
78
def get_key_from_list(key):
89
for item in list_of_dictionaries:
910
if item["id"] == key:
1011
return item
1112
"""
1213

14+
dict_setup = "from samples import dictionary_of_dictionaries"
15+
1316
lookup_list = """
1417
for key in lookups:
1518
get_key_from_list(key)
@@ -23,7 +26,9 @@ def get_key_from_list(key):
2326
lookup_list_time = timeit(
2427
stmt=lookup_list, setup=list_setup, globals=globals()
2528
)
26-
lookup_dict_time = timeit(stmt=lookup_dict, globals=globals())
29+
lookup_dict_time = timeit(
30+
stmt=lookup_dict, setup=dict_setup, globals=globals()
31+
)
2732

2833
print(
2934
f"""\

sort-python-dictionary/compare_sorting_dict_vs_list.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from timeit import timeit
2-
from samples import dictionary_of_dictionaries, list_of_dictionaries
32

43
list_program = "sorted(list_of_dictionaries, key=lambda item:item['age'])"
54
dict_program = """
@@ -10,8 +9,16 @@
109
)
1110
"""
1211

13-
list_time = timeit(stmt=list_program, globals=globals())
14-
dict_time = timeit(stmt=dict_program, globals=globals())
12+
list_time = timeit(
13+
stmt=list_program,
14+
setup="from samples import list_of_dictionaries",
15+
globals=globals(),
16+
)
17+
dict_time = timeit(
18+
stmt=dict_program,
19+
setup="from samples import dictionary_of_dictionaries",
20+
globals=globals(),
21+
)
1522

1623
print(
1724
f"""

sort-python-dictionary/nested_sort.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from operator import itemgetter
2-
31
data = {
42
193: {"name": "John", "age": 30, "skills": {"python": 8, "javascript": 7}},
53
209: {"name": "Bill", "age": 15, "skills": {"python": 6}},

0 commit comments

Comments
 (0)