Skip to content

Commit

Permalink
perf: use itertools.chain.from_iterable() instead of unpacking
Browse files Browse the repository at this point in the history
Signed-off-by: Rongrong <i@rong.moe>
  • Loading branch information
Rongronggg9 committed Nov 6, 2024
1 parent 3dfc340 commit 1f7af2b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/command/inner/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from __future__ import annotations
from typing import Any, Union, Optional
from collections.abc import Iterable, Mapping, Sequence
from collections.abc import Iterable, Sequence

import asyncio
import re
Expand Down Expand Up @@ -141,7 +141,7 @@ def push(n_: int):
for n in sorted(lang_n_per_row.keys(), reverse=True)
for i in range(0, len(lang_n_per_row[n]), n)
)
langs = tuple(chain(*lang_n_per_row.values()))
langs = tuple(chain.from_iterable(lang_n_per_row.values()))
return buttons, langs


Expand Down
2 changes: 1 addition & 1 deletion src/parsing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,4 @@ def escape_hashtags(tags: Optional[Iterable[str]]) -> Iterable[str]:


def merge_tags(*tag_lists: Optional[Iterable[str]]) -> list[str]:
return list(dict.fromkeys(chain(*tag_lists)))
return list(dict.fromkeys(chain.from_iterable(tag_lists)))

0 comments on commit 1f7af2b

Please sign in to comment.