Skip to content

Commit 9160c19

Browse files
committed
TR updates
1 parent c450459 commit 9160c19

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

python-first/chart.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
POSITION_INCREMENT = 10
1414

1515

16+
def build_list(size, fill, value, at_position):
17+
return [value if i == at_position else fill for i in range(size)]
18+
19+
1620
def find_match_loop(iterable):
1721
for val in iterable:
1822
if val["population"] > 50:
@@ -23,10 +27,6 @@ def find_match_gen(iterable):
2327
return next(val for val in iterable if val["population"] > 50)
2428

2529

26-
def build_list(size, fill, value, at_position):
27-
return [fill if i != at_position else value for i in range(size)]
28-
29-
3030
looping_times = []
3131
generator_times = []
3232
positions = []
@@ -41,7 +41,7 @@ def build_list(size, fill, value, at_position):
4141

4242
list_to_search = build_list(
4343
LIST_SIZE,
44-
{"country": "Oceania", "population": 10},
44+
{"country": "Nowhere", "population": 10},
4545
{"country": "Atlantis", "population": 100},
4646
position,
4747
)

python-first/chart_gen_loop_in.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77

88
import matplotlib.pyplot as plt
99

10-
from test_fixtures import build_list
11-
1210
TIMEIT_TIMES = 100 # Increase number for smoother lines
13-
LIST_SIZE = 10000
11+
LIST_SIZE = 1000
1412
POSITION_INCREMENT = 10
1513

1614
looping_times = []
@@ -19,6 +17,10 @@
1917
positions = []
2018

2119

20+
def build_list(size, fill, value, at_position):
21+
return [value if i == at_position else fill for i in range(size)]
22+
23+
2224
def find_match_loop(list_to_search, item_to_find):
2325
for val in list_to_search:
2426
if val == item_to_find:

python-first/test_fixtures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,4 @@
267267

268268

269269
def build_list(size, fill, value, at_position):
270-
return [fill if i != at_position else value for i in range(size)]
270+
return [value if i == at_position else fill for i in range(size)]

0 commit comments

Comments
 (0)