remove deepcopies

This commit is contained in:
Damian Stewart 2023-06-08 20:34:51 +02:00
parent a047294676
commit 17d9165c36
1 changed files with 2 additions and 2 deletions

View File

@ -13,7 +13,7 @@ def first_fit_decreasing(input_items: List[List], batch_size: int, filler_items:
def sort_by_length(items: List[List]) -> List[List]: def sort_by_length(items: List[List]) -> List[List]:
return sorted(items, key=lambda x: len(x)) return sorted(items, key=lambda x: len(x))
remaining = copy.deepcopy(input_items) remaining = input_items
output = [] output = []
while remaining: while remaining:
remaining = sort_by_length(remaining) remaining = sort_by_length(remaining)
@ -27,7 +27,7 @@ def first_fit_decreasing(input_items: List[List], batch_size: int, filler_items:
remaining.append(longest) remaining.append(longest)
else: else:
# need to build this chunk by combining multiple # need to build this chunk by combining multiple
combined = copy.deepcopy(longest) combined = longest
while True: while True:
fill_length = batch_size - len(combined) fill_length = batch_size - len(combined)
if fill_length == 0: if fill_length == 0: