Skip to content

Commit

Permalink
perf: Use operator module instead of lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Dec 22, 2024
1 parent 27b8526 commit f37ea7b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion dataset/distribution/value.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import datetime
import functools
from operator import itemgetter

from pelican.util.checks import get_empty_result_dataset
from pelican.util.getter import deep_get, get_amount, get_values
Expand Down Expand Up @@ -71,7 +72,7 @@ def get_result(scope):
result["meta"] = {"reason": "sum is 0, causing division by zero error"}
return result

sorted_values = sorted(values, key=lambda item: item["abs_amount"], reverse=True)
sorted_values = sorted(values, key=itemgetter("abs_amount"), reverse=True)
percent_size = int(count / 100)
percent_index_1 = percent_size
percent_index_5 = 5 * percent_size
Expand Down
3 changes: 2 additions & 1 deletion pelican/util/currency_converter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
import os
from operator import itemgetter

from pelican.util import settings

Expand All @@ -26,7 +27,7 @@ def import_data(data: list[tuple[datetime.date, dict[str, float]]]) -> None:
for item in data:
currencies.update(item[1].keys())

data.sort(key=lambda k: k[0])
data.sort(key=itemgetter(0))

if settings.CURRENCY_CONVERTER_INTERPOLATION:
real_data_dates: dict[str, list[datetime.date]] = {currency: [] for currency in currencies}
Expand Down

0 comments on commit f37ea7b

Please sign in to comment.