Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Use itemgetter instead of lambda #6671

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion electricitymap/contrib/lib/models/event_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from collections.abc import Sequence
from datetime import datetime
from logging import Logger
from operator import itemgetter
from typing import Any

import pandas as pd
Expand Down Expand Up @@ -60,7 +61,7 @@ def append(self, **kwargs):

def to_list(self) -> list[dict[str, Any]]:
return sorted(
[event.to_dict() for event in self.events], key=lambda x: x["datetime"]
[event.to_dict() for event in self.events], key=itemgetter("datetime")
)

@property
Expand Down
Loading